ATLAS Offline Software
Loading...
Searching...
No Matches
MuonR4::MsTrackFindingAlg Class Reference

#include <MsTrackFindingAlg.h>

Inheritance diagram for MuonR4::MsTrackFindingAlg:
Collaboration diagram for MuonR4::MsTrackFindingAlg:

Public Types

using OptBoundPars_t = Acts::Result<Acts::BoundTrackParameters>
using MeasVec_t = std::vector<const xAOD::UncalibratedMeasurement*>

Public Member Functions

virtual ~MsTrackFindingAlg ()
virtual StatusCode initialize () override final
 Standard algorithm hook to setup the extrapolator, retrieve the tools and declare algorithm's data dependencies.
virtual StatusCode execute (const EventContext &ctx) const override final
 Standard algorithm execution hook.
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::unique_ptr< MsTrackSeedContainerfindTrackSeeds (const EventContext &ctx, const xAOD::MuonSegmentContainer &segments) const
 Iterates over the search tree and combines close-by segments to a track seed.
bool fitSeedCandidate (const Acts::GeometryContext &gCtx, const Acts::MagneticFieldContext &mCtx, const Acts::CalibrationContext &cCtx, const MsTrackSeed &seed, ActsTrk::MutableTrackContainer &outContainer) const
 Attempts to fit the track seed candidate to a full track and returns whether the fit succeeded.
std::pair< OptBoundPars_t, MeasVec_tprepareFit (const Acts::GeometryContext &tgContext, const Acts::MagneticFieldContext &mfContext, const Acts::CalibrationContext &calContext, const MsTrackSeed &seed) const
 Prepares the input by the fit by collecting the measurements on the segment &.
const MsTrackSeederbaselineSeeder () const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< xAOD::MuonSegmentContainerm_segmentKey {this, "SegmentContainer", "MuonSegmentsFromR4" }
 Declare the data dependency on the standard Mdt+Rpc+Tgc segment container & on the NSW segment container.
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 IdHelperSvc to decode the Identifiers.
const MuonGMR4::MuonDetectorManagerm_detMgr {nullptr}
 Pointer to the MuonDetectorManager.
SG::WriteHandleKey< MsTrackSeedContainerm_msTrkSeedKey {this, "MsTrkSeedKey", "MsTrackSeeds"}
 Temporary container write handle to push the seeds to store gate for later efficiency analysis.
ToolHandle< ISegmentSelectionToolm_segSelector {this, "SegmentSelectionTool" , "" }
 Segment selection tool to pick the good quality segments.
ToolHandle< ActsTrk::IFitterToolm_trackFitTool {this, "FittingTool", ""}
 Track fitting tool.
ToolHandle< ISpacePointCalibratorm_calibTool {this, "Calibrator", ""}
 Calibration tool to fill the track states.
PublicToolHandle< ActsTrk::ITrackingGeometryToolm_trackingGeometryTool {this, "TrackingGeometryTool", ""}
 Tracking geometry tool.
ToolHandle< ActsTrk::IExtrapolationToolm_extrapolationTool {this, "ExtrapolationTool" ,"" }
 Track extrapolation tool.
ToolHandle< MuonValR4::ITrackVisualizationToolm_visualizationTool {this, "VisualizationTool", ""}
 Visualization tool to debug the track finding.
Gaudi::Property< double > m_seedHalfLength {this, "SeedHalfLength", 50.*Gaudi::Units::cm}
 Maximum search window to search segments for.
SG::WriteHandleKey< ActsTrk::TrackContainerm_writeKey {this, "TrackWriteKey", "MsTracks"}
 Key to the output track container.
Gaudi::Property< bool > m_useMlSeeder {this, "UseMlSeeder", false, "Use segment-edge ML candidate ids to split seeding"}
 Use ML-guided segment grouping before baseline seeding.
Gaudi::Property< std::string > m_mlCandidateDecoration {this, "MlCandidateDecoration", "trackCandidateIds", "Segment vector<unsigned> decoration with ML track-candidate ids"}
 Segment decoration containing vector<unsigned> candidate IDs.
Gaudi::Property< unsigned > m_mlMinSegmentsPerCandidate {this, "MlMinSegmentsPerCandidate", 2}
Gaudi::Property< bool > m_mlFallbackToBaselineIfUndecorated
Gaudi::Property< bool > m_mlFallbackToBaselineIfNoCandidates
Gaudi::Property< bool > m_mlRunCandidatesInParallel
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainerm_mlCandidateDecorKey
std::unique_ptr< MsTrackSeederm_seeder {}
 Pointer to the actual seeder implementation.
std::unique_ptr< MlMsTrackSeederm_mlSeeder {}
 Optional ML-wrapper seeder implementation.
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 39 of file MsTrackFindingAlg.h.

Member Typedef Documentation

◆ MeasVec_t

◆ OptBoundPars_t

using MuonR4::MsTrackFindingAlg::OptBoundPars_t = Acts::Result<Acts::BoundTrackParameters>

Definition at line 50 of file MsTrackFindingAlg.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ~MsTrackFindingAlg()

MuonR4::MsTrackFindingAlg::~MsTrackFindingAlg ( )
virtualdefault

Member Function Documentation

◆ baselineSeeder()

const MsTrackSeeder & MuonR4::MsTrackFindingAlg::baselineSeeder ( ) const
private

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

62{
63 return 0;
64}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode MuonR4::MsTrackFindingAlg::execute ( const EventContext & ctx) const
finaloverridevirtual

Standard algorithm execution hook.

Attach the number of the parent seed to the output container

Definition at line 64 of file MsTrackFindingAlg.cxx.

64 {
65 ATH_MSG_VERBOSE("Run track finding in event "<<ctx.eventID().event_number());
66
67 const xAOD::MuonSegmentContainer* allEventSegs{nullptr};
68 ATH_CHECK(SG::get(allEventSegs, m_segmentKey, ctx));
69
70 auto seedContainer = findTrackSeeds(ctx, *allEventSegs);
71
72 const Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
73 const Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
74 const Acts::CalibrationContext calContext{ActsTrk::getCalibrationContext(ctx)};
75
76
77 Acts::VectorTrackContainer trackBackend{};
78 Acts::VectorMultiTrajectory trackStateBackend{};
79 ActsTrk::MutableTrackContainer cacheTrkContainer{std::move(trackBackend),
80 std::move(trackStateBackend)};
82 cacheTrkContainer.addColumn<std::size_t>("parentSeed");
83 unsigned seedIdx{0};
84 for (const MsTrackSeed& seed : *seedContainer) {
85 if (!fitSeedCandidate(tgContext, mfContext, calContext, seed,
86 cacheTrkContainer)) {
87 ++seedIdx;
88 continue;
89 }
90 auto lastTrack = cacheTrkContainer.getTrack(cacheTrkContainer.size() -1);
91 lastTrack.component<std::size_t, Acts::hashString("parentSeed")>() = seedIdx;
92 ++seedIdx;
93 }
94 SG::WriteHandle writeHandleSeed{m_msTrkSeedKey, ctx};
95 ATH_CHECK(writeHandleSeed.record(std::move(seedContainer)));
96
97 // Constant declination
98 Acts::ConstVectorTrackContainer ctrackBackend{std::move(cacheTrkContainer.container())};
99 Acts::ConstVectorMultiTrajectory ctrackStateBackend{std::move(cacheTrkContainer.trackStateContainer())};
100 auto ctc = std::make_unique<ActsTrk::TrackContainer>(std::move(ctrackBackend),
101 std::move(ctrackStateBackend));
102
103 SG::WriteHandle writeHandle{m_writeKey, ctx};
104 ATH_CHECK(writeHandle.record(std::move(ctc)));
105 return StatusCode::SUCCESS;
106 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
std::unique_ptr< MsTrackSeedContainer > findTrackSeeds(const EventContext &ctx, const xAOD::MuonSegmentContainer &segments) const
Iterates over the search tree and combines close-by segments to a track seed.
SG::WriteHandleKey< ActsTrk::TrackContainer > m_writeKey
Key to the output track container.
SG::WriteHandleKey< MsTrackSeedContainer > m_msTrkSeedKey
Temporary container write handle to push the seeds to store gate for later efficiency analysis.
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Tracking geometry tool.
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
Track extrapolation tool.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Declare the data dependency on the standard Mdt+Rpc+Tgc segment container & on the NSW segment contai...
bool fitSeedCandidate(const Acts::GeometryContext &gCtx, const Acts::MagneticFieldContext &mCtx, const Acts::CalibrationContext &cCtx, const MsTrackSeed &seed, ActsTrk::MutableTrackContainer &outContainer) const
Attempts to fit the track seed candidate to a full track and returns whether the fit succeeded.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

88{
89 // If we didn't find any symlinks to add, just return the collection
90 // from the base class. Otherwise, return the extended collection.
91 if (!m_extendedExtraObjects.empty()) {
93 }
95}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ findTrackSeeds()

std::unique_ptr< MsTrackSeedContainer > MuonR4::MsTrackFindingAlg::findTrackSeeds ( const EventContext & ctx,
const xAOD::MuonSegmentContainer & segments ) const
private

Iterates over the search tree and combines close-by segments to a track seed.

Seeds with the same segments as other seeds are deduplicated

Parameters
ctxThe event's context to access StoreGate & Conditions
segmentsFull segment container

Definition at line 109 of file MsTrackFindingAlg.cxx.

110 {
111
112 auto seedContainer = m_seeder->findTrackSeeds(ctx, m_trackingGeometryTool->getGeometryContext(ctx), segments);
113
114 if (!m_visualizationTool.empty()) {
115 m_visualizationTool->displaySeeds(ctx, *m_seeder, segments, *seedContainer);
116 }
117 return seedContainer;
118 }
std::unique_ptr< MsTrackSeeder > m_seeder
Pointer to the actual seeder implementation.
ToolHandle< MuonValR4::ITrackVisualizationTool > m_visualizationTool
Visualization tool to debug the track finding.

◆ fitSeedCandidate()

bool MuonR4::MsTrackFindingAlg::fitSeedCandidate ( const Acts::GeometryContext & gCtx,
const Acts::MagneticFieldContext & mCtx,
const Acts::CalibrationContext & cCtx,
const MsTrackSeed & seed,
ActsTrk::MutableTrackContainer & outContainer ) const
private

Attempts to fit the track seed candidate to a full track and returns whether the fit succeeded.

Parameters
gCtxGeometry context to access the alignment of the surfaces
mCtxcMagnetic field context to access the field map during the fit
cCtxCalibration context to access the calibration constants from Store gate during the track state filling
seedThe seed of interest to fit
outContainerMutable track container to which the output track is written

Definition at line 241 of file MsTrackFindingAlg.cxx.

245 {
246
247 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Attempt to fit a new track seed \n"<<seed);
248 const EventContext& ctx{*calContext.get<const EventContext*>()};
249 const auto [initialPars, measurements] = prepareFit(tgContext, mfContext, calContext, seed);
250
251 if (!initialPars.ok()) {
252 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - Failed to construct valid parameters for seed \n"<<seed);
253 if (m_visualizationTool.isEnabled()) {
254 m_visualizationTool->displayTrackSeedObj(ctx, seed, initialPars, "FailedStartPars");
255 }
256 return false;
257 }
258 auto fitTraject = m_trackFitTool->fit(measurements, *initialPars,
259 tgContext, mfContext, calContext,
260 &(*initialPars).referenceSurface());
261 if (!fitTraject || fitTraject->size() == 0) {
262 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Fit failed ");
263 if (m_visualizationTool.isEnabled()) {
264 m_visualizationTool->displayTrackSeedObj(ctx, seed, initialPars, "FailedFit");
265 }
266 return false;
267 }
268 outContainer.ensureDynamicColumns(*fitTraject);
269 auto destProxy = outContainer.getTrack(outContainer.addTrack());
270 destProxy.copyFrom(fitTraject->getTrack(0));
271 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Good track fit...");
272 if (m_visualizationTool.isEnabled()) {
273 m_visualizationTool->displayTrackSeedObj(ctx, seed,
274 destProxy.createParametersAtReference(), "GoodFit");
275 }
276 for (const auto state : destProxy.trackStates()) {
277 if (!state.hasUncalibratedSourceLink()){
278 continue;
279 }
280 auto meas = ActsTrk::detail::xAODUncalibMeasCalibrator::unpack(state.getUncalibratedSourceLink());
281 ATH_MSG_DEBUG("Accepted measurement "<<m_idHelperSvc->toString(xAOD::identify(meas))
282 <<", "<<xAOD::muonSurface(meas).geometryId());
283 }
284 return true;
285 }
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static const xAOD::UncalibratedMeasurement * unpack(const Acts::SourceLink &sl)
Helper method to unpack an Acts source link to an uncalibrated measurement.
ToolHandle< ActsTrk::IFitterTool > m_trackFitTool
Track fitting tool.
std::pair< OptBoundPars_t, MeasVec_t > prepareFit(const Acts::GeometryContext &tgContext, const Acts::MagneticFieldContext &mfContext, const Acts::CalibrationContext &calContext, const MsTrackSeed &seed) const
Prepares the input by the fit by collecting the measurements on the segment &.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
IdHelperSvc to decode the Identifiers.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
const Acts::Surface & muonSurface(const UncalibratedMeasurement *meas)
Returns the associated Acts surface to the measurement.

◆ initialize()

StatusCode MuonR4::MsTrackFindingAlg::initialize ( )
finaloverridevirtual

Standard algorithm hook to setup the extrapolator, retrieve the tools and declare algorithm's data dependencies.

Definition at line 33 of file MsTrackFindingAlg.cxx.

33 {
34 ATH_CHECK(m_segmentKey.initialize());
35 ATH_CHECK(m_idHelperSvc.retrieve());
36 ATH_CHECK(detStore()->retrieve(m_detMgr));
37 ATH_CHECK(m_segSelector.retrieve());
38 ATH_CHECK(m_msTrkSeedKey.initialize());
39
40 ATH_CHECK(m_visualizationTool.retrieve(EnableTool{!m_visualizationTool.empty()}));
43 ATH_CHECK(m_trackFitTool.retrieve());
44 ATH_CHECK(m_calibTool.retrieve());
45 ATH_CHECK(m_writeKey.initialize());
46
47 if (m_trackingGeometryTool->trackingGeometry()->geometryVersion() !=
48 Acts::TrackingGeometry::GeometryVersion::Gen3){
49 ATH_MSG_ERROR("The MS track fit requires the Gen 3 geometry format");
50 return StatusCode::FAILURE;
51 }
52
53 MsTrackSeeder::Config seederCfg{};
54 seederCfg.seedHalfLength = m_seedHalfLength;
55 seederCfg.selector = m_segSelector.get();
56 seederCfg.detMgr = m_detMgr;
57
58 m_seeder = std::make_unique<MsTrackSeeder>(name(), std::move(seederCfg));
59 return StatusCode::SUCCESS;
60 }
#define ATH_MSG_ERROR(x)
const ServiceHandle< StoreGateSvc > & detStore() const
Gaudi::Property< double > m_seedHalfLength
Maximum search window to search segments for.
ToolHandle< ISpacePointCalibrator > m_calibTool
Calibration tool to fill the track states.
const MuonGMR4::MuonDetectorManager * m_detMgr
Pointer to the MuonDetectorManager.
ToolHandle< ISegmentSelectionTool > m_segSelector
Segment selection tool to pick the good quality segments.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ prepareFit()

std::pair< MsTrackFindingAlg::OptBoundPars_t, MsTrackFindingAlg::MeasVec_t > MuonR4::MsTrackFindingAlg::prepareFit ( const Acts::GeometryContext & tgContext,
const Acts::MagneticFieldContext & mfContext,
const Acts::CalibrationContext & calContext,
const MsTrackSeed & seed ) const
private

Prepares the input by the fit by collecting the measurements on the segment &.

Parameters
gCtxGeometry context to access the alignment of the surfaces
mCtxcMagnetic field context to access the field map during the fit
cCtxCalibration context to access the calibration constants from Store gate during the track state filling
seedThe seed of interest to fit

Fetch the measurements from the segment & find the first segment which has phi hits

Ensure that the drift signs from the fit are stamped onto the Uncalibrated measurements

The middle or outer segment provide the phi information. Not so easy becasue we want to Take the y0 & precision direction from the inner segment but the phi & x0 from a straight line extrapolation onto the plane

Create a surface shortly before the first measurement that belongs to a valid volume. Trigger and phi layer hits may have surface geometry IDs that don't map to a named tracking volume (e.g., they belong to a gap region), even though the measurements are valid and used in the fit. We search for the first precision measurement whose geometry ID successfully resolves to a named Acts::TrackingVolume so we can extract a boundary surface to seed the track parameters.

Definition at line 121 of file MsTrackFindingAlg.cxx.

124 {
125 const EventContext& ctx{*calContext.get<const EventContext*>()};
126 MeasVec_t measurements{};
127 measurements.reserve(100);
129 const xAOD::MuonSegment* refSeg{nullptr};
130 for (const xAOD::MuonSegment* segment : seed.segments()) {
132 m_calibTool->stampSignsOnMeasurements(*segment);
133 MeasVec_t segMeasurements = collectMeasurements(*segment, /*skipOutlier:*/ true);
134 if (msgLvl(MSG::VERBOSE)) {
135 std::stringstream sstr{};
136 for (const xAOD::UncalibratedMeasurement* m : segMeasurements) {
137 const Acts::Surface& surf{xAOD::muonSurface(m)};
138 sstr<<" *** "<<m_idHelperSvc->toString(xAOD::identify(m))
139 <<", "<<m->numDimensions()<<", "
140 <<", "<<surf.geometryId()<<" @ "<<Amg::toString(surf.localToGlobalTransform(tgContext))<<std::endl;
141 }
142 ATH_MSG_VERBOSE("Fetch measurements from segment: "<<Amg::toString(segment->position())
143 <<", direction: "<<Amg::toString(segment->direction())<<"\n"<<sstr.str());
144 }
145 measurements.insert(measurements.end(),
146 std::make_move_iterator(segMeasurements.begin()),
147 std::make_move_iterator(segMeasurements.end()));
148
149 if (!refSeg && m_segSelector->passSeedingQuality(ctx, *detailedSegment(*segment))) {
150 refSeg = segment;
151 }
152 }
153 if (!refSeg || measurements.empty()) {
154 ATH_MSG_WARNING(__func__<<"() "<<__LINE__
155 <<" - No reference segment passing seeding quality "<<
156 (refSeg != nullptr)<<" was found. #"<<measurements.size()<<" measurements. ");
157 return std::make_pair(Acts::Result<Acts::BoundTrackParameters>::failure(std::make_error_code(std::errc::invalid_argument)),
158 std::vector<const xAOD::UncalibratedMeasurement_v1*>{});
159 }
160 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - "<<measurements.size()<<" measurements");
161 Amg::Vector3D seedPos{refSeg->position()};
162 Amg::Vector3D seedDir{refSeg->direction()};
166 if (refSeg != seed.segments().front()) {
167 const MuonGMR4::SpectrometerSector* innerPlane = m_seeder->envelope(*seed.segments().front());
168 const Acts::PlaneSurface& surf = innerPlane->surface();
169 const Amg::Transform3D toInnerPlane = surf.localToGlobalTransform(tgContext).inverse();
170 const Amg::Vector3D locSeedPos = toInnerPlane * seedPos;
171 const Amg::Vector3D locSeedDir = toInnerPlane.linear() * seedDir;
172
173 auto seedOnInner = Acts::PlanarHelper::intersectPlane(locSeedPos, locSeedDir,
174 Amg::Vector3D::UnitZ(), 0.);
175
176 using enum SegmentFit::ParamDefs;
177 SegmentFit::Parameters innerPars = SegmentFit::localSegmentPars(*seed.segments().front());
178 innerPars[Acts::toUnderlying(x0)] = seedOnInner.position().x();
179 const Amg::Vector3D innerSegDir =
180 Acts::makeDirectionFromPhiTheta(innerPars[Acts::toUnderlying(phi)],
181 innerPars[Acts::toUnderlying(theta)]);
182 const Amg::Vector3D combSegDir =
183 Acts::makeDirectionFromAxisTangents(houghTanAlpha(locSeedDir),
184 houghTanBeta(innerSegDir));
185 seedPos = surf.localToGlobalTransform(tgContext) * Amg::Vector3D{innerPars[Acts::toUnderlying(x0)],
186 innerPars[Acts::toUnderlying(y0)], 0};
187 seedDir = surf.localToGlobalTransform(tgContext).linear() * combSegDir;
188 }
195 const xAOD::UncalibratedMeasurement* firstVolumeMeas{nullptr};
196 const Acts::TrackingVolume* volume{nullptr};
197 for (const xAOD::UncalibratedMeasurement* meas : measurements) {
198 const Acts::GeometryIdentifier volId = volumeId(xAOD::muonSurface(meas));
199 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Check measurement "
200 <<m_idHelperSvc->toString(xAOD::identify(meas))<<", "<<xAOD::muonSurface(meas).geometryId());
201 volume = m_trackingGeometryTool->trackingGeometry()->findVolume(volId);
202 if (volume) {
203 firstVolumeMeas = meas;
204 break;
205 }
206 }
207
208 if (!volume) {
209 ATH_MSG_WARNING(__func__<<"() "<<__LINE__
210 <<" - Failed to find tracking volume for any seed measurement");
211 return std::make_pair(Acts::Result<Acts::BoundTrackParameters>::failure(std::make_error_code(std::errc::invalid_argument)),
212 std::vector<const xAOD::UncalibratedMeasurement_v1*>{});
213 }
214 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Using seed measurement "
215 << m_idHelperSvc->toString(xAOD::identify(firstVolumeMeas))
216 << " with volume id " << volumeId(xAOD::muonSurface(firstVolumeMeas)));
217
218 auto boundSurf = MuonGMR4::bottomBoundary(*volume);
219 if (!boundSurf) {
220 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - Failed to find boundary surface for tracking volume");
221 return std::make_pair(Acts::Result<Acts::BoundTrackParameters>::failure(std::make_error_code(std::errc::invalid_argument)),
222 std::vector<const xAOD::UncalibratedMeasurement_v1*>{});
223 }
224 auto targetSurf = boundSurf->getSharedPtr();
225 using namespace Acts::PlanarHelper;
226
227 auto pIsect = intersectPlane(seedPos, seedDir,
228 targetSurf->localToGlobalTransform(tgContext).linear().col(2),
229 targetSurf->center(tgContext));
230
231 auto fourPos = ActsTrk::convertPosToActs(pIsect.position(), pIsect.position().mag() / Gaudi::Units::c_light);
232 const double qOverP = 1./ m_seeder->estimateQtimesP(*tgContext.get<const ActsTrk::GeometryContext*>(),
233 *mfContext.get<const AtlasFieldCacheCondObj*>(), seed);
234 auto initialPars = Acts::BoundTrackParameters::create(tgContext, targetSurf, fourPos,
235 seedDir, ActsTrk::energyToActs(qOverP),
236 Acts::BoundMatrix::Identity(),
237 Acts::ParticleHypothesis::muon());
238 return std::make_pair(std::move(initialPars), std::move(measurements));
239
240 }
Scalar phi() const
phi method
Scalar theta() const
theta method
bool msgLvl(const MSG::Level lvl) const
const Acts::PlaneSurface & surface() const
Returns the associated surface.
std::vector< const xAOD::UncalibratedMeasurement * > MeasVec_t
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
constexpr double energyToActs(const double athenaE)
Converts an energy scalar from Athena to Acts units.
Acts::Vector4 convertPosToActs(const Amg::Vector3D &athenaPos, const double athenaTime=0.)
Converts a position vector & time from Athena units into Acts units.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
@ qOverP
perigee
const Acts::Surface * bottomBoundary(const Acts::TrackingVolume &volume)
Returns the boundary surface parallel to the x-y plane at negative local z.
SeedingAux::FitParIndex ParamDefs
Use the same parameter indices as used by the CompSpacePointAuxiliaries.
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
Acts::Experimental::CompositeSpacePointLineFitter::ParamVec_t Parameters
double houghTanBeta(const Amg::Vector3D &v)
Returns the hough tanBeta [y] / [z].
std::vector< const xAOD::UncalibratedMeasurement * > collectMeasurements(const xAOD::MuonSegment &segment, bool skipOutlier=true)
Helper function to extract the measurements from the segment.
Acts::GeometryIdentifier volumeId(const Acts::Surface &surface)
Returns the identifier of the volume in which the surface is embedded.
double houghTanAlpha(const Amg::Vector3D &v)
: Returns the hough tanAlpha [x] / [z]
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

75{
76 return BaseAlg::sysExecute (ctx);
77}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

105 {
107
108 if (sc.isFailure()) {
109 return sc;
110 }
111
112 ServiceHandle<ICondSvc> cs("CondSvc",name());
113 for (auto h : outputHandles()) {
114 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
115 // do this inside the loop so we don't create the CondSvc until needed
116 if ( cs.retrieve().isFailure() ) {
117 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
118 return StatusCode::SUCCESS;
119 }
120 if (cs->regHandle(this,*h).isFailure()) {
122 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
123 << " with CondSvc");
124 }
125 }
126 }
127 return sc;
128}
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

Member Data Documentation

◆ m_calibTool

ToolHandle<ISpacePointCalibrator> MuonR4::MsTrackFindingAlg::m_calibTool {this, "Calibrator", ""}
private

Calibration tool to fill the track states.

Definition at line 101 of file MsTrackFindingAlg.h.

101{this, "Calibrator", ""};

◆ m_detMgr

const MuonGMR4::MuonDetectorManager* MuonR4::MsTrackFindingAlg::m_detMgr {nullptr}
private

Pointer to the MuonDetectorManager.

Definition at line 93 of file MsTrackFindingAlg.h.

93{nullptr};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_extrapolationTool

ToolHandle<ActsTrk::IExtrapolationTool> MuonR4::MsTrackFindingAlg::m_extrapolationTool {this, "ExtrapolationTool" ,"" }
private

Track extrapolation tool.

Definition at line 105 of file MsTrackFindingAlg.h.

105{this, "ExtrapolationTool" ,"" };

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonR4::MsTrackFindingAlg::m_idHelperSvc {this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

IdHelperSvc to decode the Identifiers.

Definition at line 91 of file MsTrackFindingAlg.h.

91{this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_mlCandidateDecoration

Gaudi::Property<std::string> MuonR4::MsTrackFindingAlg::m_mlCandidateDecoration {this, "MlCandidateDecoration", "trackCandidateIds", "Segment vector<unsigned> decoration with ML track-candidate ids"}
private

Segment decoration containing vector<unsigned> candidate IDs.

Definition at line 115 of file MsTrackFindingAlg.h.

115{this, "MlCandidateDecoration", "trackCandidateIds", "Segment vector<unsigned> decoration with ML track-candidate ids"};

◆ m_mlCandidateDecorKey

SG::ReadDecorHandleKey<xAOD::MuonSegmentContainer> MuonR4::MsTrackFindingAlg::m_mlCandidateDecorKey
private
Initial value:
{
this, "MlCandidateDecorationKey", "", "Scheduler dependency on ML candidate decoration"}

Definition at line 126 of file MsTrackFindingAlg.h.

126 {
127 this, "MlCandidateDecorationKey", "", "Scheduler dependency on ML candidate decoration"};

◆ m_mlFallbackToBaselineIfNoCandidates

Gaudi::Property<bool> MuonR4::MsTrackFindingAlg::m_mlFallbackToBaselineIfNoCandidates
private
Initial value:
{
this, "MlFallbackToBaselineIfNoCandidates", false,
"Run baseline seeder if ML grouping produced no seed candidates"}

Definition at line 120 of file MsTrackFindingAlg.h.

120 {
121 this, "MlFallbackToBaselineIfNoCandidates", false,
122 "Run baseline seeder if ML grouping produced no seed candidates"};

◆ m_mlFallbackToBaselineIfUndecorated

Gaudi::Property<bool> MuonR4::MsTrackFindingAlg::m_mlFallbackToBaselineIfUndecorated
private
Initial value:
{
this, "MlFallbackToBaselineIfUndecorated", true,
"Run baseline seeder if the input segment container has no ML decoration"}

Definition at line 117 of file MsTrackFindingAlg.h.

117 {
118 this, "MlFallbackToBaselineIfUndecorated", true,
119 "Run baseline seeder if the input segment container has no ML decoration"};

◆ m_mlMinSegmentsPerCandidate

Gaudi::Property<unsigned> MuonR4::MsTrackFindingAlg::m_mlMinSegmentsPerCandidate {this, "MlMinSegmentsPerCandidate", 2}
private

Definition at line 116 of file MsTrackFindingAlg.h.

116{this, "MlMinSegmentsPerCandidate", 2};

◆ m_mlRunCandidatesInParallel

Gaudi::Property<bool> MuonR4::MsTrackFindingAlg::m_mlRunCandidatesInParallel
private
Initial value:
{
this, "MlRunCandidatesInParallel", true,
"Run baseline seeding independently for ML candidate groups in parallel"}

Definition at line 123 of file MsTrackFindingAlg.h.

123 {
124 this, "MlRunCandidatesInParallel", true,
125 "Run baseline seeding independently for ML candidate groups in parallel"};

◆ m_mlSeeder

std::unique_ptr<MlMsTrackSeeder> MuonR4::MsTrackFindingAlg::m_mlSeeder {}
private

Optional ML-wrapper seeder implementation.

Definition at line 131 of file MsTrackFindingAlg.h.

131{};

◆ m_msTrkSeedKey

SG::WriteHandleKey<MsTrackSeedContainer> MuonR4::MsTrackFindingAlg::m_msTrkSeedKey {this, "MsTrkSeedKey", "MsTrackSeeds"}
private

Temporary container write handle to push the seeds to store gate for later efficiency analysis.

Definition at line 95 of file MsTrackFindingAlg.h.

95{this, "MsTrkSeedKey", "MsTrackSeeds"};

◆ m_seeder

std::unique_ptr<MsTrackSeeder> MuonR4::MsTrackFindingAlg::m_seeder {}
private

Pointer to the actual seeder implementation.

Definition at line 129 of file MsTrackFindingAlg.h.

129{};

◆ m_seedHalfLength

Gaudi::Property<double> MuonR4::MsTrackFindingAlg::m_seedHalfLength {this, "SeedHalfLength", 50.*Gaudi::Units::cm}
private

Maximum search window to search segments for.

Definition at line 109 of file MsTrackFindingAlg.h.

109{this, "SeedHalfLength", 50.*Gaudi::Units::cm};

◆ m_segmentKey

SG::ReadHandleKey<xAOD::MuonSegmentContainer> MuonR4::MsTrackFindingAlg::m_segmentKey {this, "SegmentContainer", "MuonSegmentsFromR4" }
private

Declare the data dependency on the standard Mdt+Rpc+Tgc segment container & on the NSW segment container.

Definition at line 89 of file MsTrackFindingAlg.h.

89{this, "SegmentContainer", "MuonSegmentsFromR4" };

◆ m_segSelector

ToolHandle<ISegmentSelectionTool> MuonR4::MsTrackFindingAlg::m_segSelector {this, "SegmentSelectionTool" , "" }
private

Segment selection tool to pick the good quality segments.

Definition at line 97 of file MsTrackFindingAlg.h.

97{this, "SegmentSelectionTool" , "" };

◆ m_trackFitTool

ToolHandle<ActsTrk::IFitterTool> MuonR4::MsTrackFindingAlg::m_trackFitTool {this, "FittingTool", ""}
private

Track fitting tool.

Definition at line 99 of file MsTrackFindingAlg.h.

99{this, "FittingTool", ""};

◆ m_trackingGeometryTool

PublicToolHandle<ActsTrk::ITrackingGeometryTool> MuonR4::MsTrackFindingAlg::m_trackingGeometryTool {this, "TrackingGeometryTool", ""}
private

Tracking geometry tool.

Definition at line 103 of file MsTrackFindingAlg.h.

103{this, "TrackingGeometryTool", ""};

◆ m_useMlSeeder

Gaudi::Property<bool> MuonR4::MsTrackFindingAlg::m_useMlSeeder {this, "UseMlSeeder", false, "Use segment-edge ML candidate ids to split seeding"}
private

Use ML-guided segment grouping before baseline seeding.

Definition at line 113 of file MsTrackFindingAlg.h.

113{this, "UseMlSeeder", false, "Use segment-edge ML candidate ids to split seeding"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_visualizationTool

ToolHandle<MuonValR4::ITrackVisualizationTool> MuonR4::MsTrackFindingAlg::m_visualizationTool {this, "VisualizationTool", ""}
private

Visualization tool to debug the track finding.

Definition at line 107 of file MsTrackFindingAlg.h.

107{this, "VisualizationTool", ""};

◆ m_writeKey

SG::WriteHandleKey<ActsTrk::TrackContainer> MuonR4::MsTrackFindingAlg::m_writeKey {this, "TrackWriteKey", "MsTracks"}
private

Key to the output track container.

Definition at line 111 of file MsTrackFindingAlg.h.

111{this, "TrackWriteKey", "MsTracks"};

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