ATLAS Offline Software
Loading...
Searching...
No Matches
TrackFindingAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7// Athena
12
13// ACTS
14#include "Acts/Geometry/TrackingGeometry.hpp"
15#include "Acts/Geometry/GeometryIdentifier.hpp"
16#include "Acts/Utilities/Helpers.hpp"
17#include "Acts/Utilities/TrackHelpers.hpp"
18#include "Acts/TrackFitting/MbfSmoother.hpp"
19#include "Acts/Utilities/Logger.hpp"
20#include "ActsInterop/Logger.h"
22
23// ActsTrk
24
27
32
33// STL
34#include <Acts/Propagator/StandardAborters.hpp>
35#include <sstream>
36#include <functional>
37#include <stdexcept>
38#include <utility>
39#include <algorithm>
40#include <variant>
41
42namespace {
43
44 static std::optional<ActsTrk::detail::RecoTrackStateContainerProxy> getFirstMeasurementFromTrack(typename ActsTrk::detail::RecoTrackContainer::TrackProxy trackProxy) {
45 std::optional<ActsTrk::detail::RecoTrackStateContainerProxy> firstMeasurement {std::nullopt};
46 for (auto st : trackProxy.trackStatesReversed()) {
47 // We are excluding non measurement states and outlier here. Those can
48 // decrease resolution because only the smoothing corrected the very
49 // first prediction as filtering is not possible.
50 if (not st.typeFlags().hasMeasurement()) continue;
51 if (st.typeFlags().isOutlier()) continue;
53 }
54 return firstMeasurement;
55 }
56
57}
58
59
60
61namespace ActsTrk
62{
64
65 TrackFindingAlg::TrackFindingAlg(const std::string &name, ISvcLocator *pSvcLocator)
66 : TrackFindingBaseAlg(name, pSvcLocator) {}
67
68 // === initialize ==========================================================
69
71 {
72 ATH_MSG_INFO("Initializing " << name() << " ... ");
73
85
87 ATH_CHECK(m_seedContainerKeys.initialize());
90 ATH_CHECK(m_detElStatus.initialize());
91 ATH_CHECK(m_beamSpotKey.initialize());
92
93 m_storeDestinies = not m_seedDestiny.empty();
95
96 if (m_paramEstimationTool.size() != m_seedContainerKeys.size()) {
97 ATH_MSG_FATAL("There are " << m_seedContainerKeys.size() << " SeedContainerKeys. Each needs its own TrackParamsEstimationTool, but there are " << m_paramEstimationTool.size());
98 }
99
100 if (m_useTopSpRZboundary.size() != 2)
101 {
102 ATH_MSG_FATAL("useTopSpRZboundary must have 2 elements, but has " << m_useTopSpRZboundary.size());
103 return StatusCode::FAILURE;
104 }
105
106 if (m_ambiStrategy != 0u /* OUTSIDE_TF */) m_showResolvedStats = true;
107 if (m_ambiStrategy == 1u /* END_OF_TF */) {
108 Acts::GreedyAmbiguityResolution::Config cfg;
109 cfg.maximumSharedHits = m_maximumSharedHits;
110 cfg.maximumIterations = m_maximumIterations;
111 cfg.nMeasurementsMin = m_nMeasurementsMin;
112
113 m_ambi.emplace(std::move(cfg), makeActsAthenaLogger(this, "Acts"));
114 }
115
116 if (m_storeDestinies) {
117 if (m_seedDestiny.size() != m_seedContainerKeys.size()) {
118 ATH_MSG_ERROR("There are " << m_seedDestiny.size() << " seed destiny collections, but " << m_seedContainerKeys.size() << " seed collections");
119 return StatusCode::FAILURE;
120 }
121 }
122
123 return StatusCode::SUCCESS;
124 }
125
126 // === finalize ============================================================
127
130 return StatusCode::SUCCESS;
131 }
132
133 // === execute =============================================================
134
135 StatusCode TrackFindingAlg::execute(const EventContext &ctx) const
136 {
137 ATH_MSG_DEBUG("Executing " << name() << " ... ");
138
139 auto timer = Monitored::Timer<std::chrono::milliseconds>("TIME_execute");
140 auto mon_nTracks = Monitored::Scalar<int>("nTracks");
141 auto mon = Monitored::Group(m_monTool, timer, mon_nTracks);
142
143 // ================================================== //
144 // ===================== INPUTS ===================== //
145 // ================================================== //
146
147 // SEED TRIPLETS
148 std::vector<const ActsTrk::SeedContainer *> seedContainers;
149 std::size_t total_seeds = 0;
150 ATH_CHECK(getContainersFromKeys(ctx, m_seedContainerKeys, seedContainers, total_seeds));
151
152 // DESTINIES
153 std::vector< std::unique_ptr< std::vector<int> > > destinies {};
154 if (m_storeDestinies) {
155 destinies.reserve( seedContainers.size() );
156 for (std::size_t i(0); i<seedContainers.size(); ++i) {
157 destinies.push_back( std::make_unique< std::vector<int> >( seedContainers.at(i)->size(), DestinyType::UNKNOWN) );
158 }
159 }
160
161 // MEASUREMENTS
162 std::vector<const xAOD::UncalibratedMeasurementContainer *> uncalibratedMeasurementContainers;
163 std::size_t total_measurements = 0;
164 ATH_CHECK(getContainersFromKeys(ctx, m_uncalibratedMeasurementContainerKeys, uncalibratedMeasurementContainers, total_measurements));
165
166 // map detector element status to volume ids
168 volumeIdToDetectorElementCollMap(m_volumeIdToDetectorElementCollMapKey,ctx);
169 ATH_CHECK(volumeIdToDetectorElementCollMap.isValid());
170 std::vector< const InDet::SiDetectorElementStatus *> det_el_status_arr;
171 const std::vector<const InDetDD::SiDetectorElementCollection*> &det_el_collections =volumeIdToDetectorElementCollMap->collections();
172 det_el_status_arr.resize( det_el_collections.size(), nullptr);
174 SG::ReadHandle<InDet::SiDetectorElementStatus> det_el_status(det_el_status_key,ctx);
175 ATH_CHECK( det_el_status.isValid());
176 const std::vector<const InDetDD::SiDetectorElementCollection*>::const_iterator
177 det_el_col_iter = std::find(det_el_collections.begin(),
178 det_el_collections.end(),
179 &det_el_status->getDetectorElements());
180 det_el_status_arr.at(det_el_col_iter - det_el_collections.begin()) = det_el_status.cptr();
181 }
182
183 detail::MeasurementIndex measurementIndex(uncalibratedMeasurementContainers.size());
184 for (std::size_t icontainer = 0; icontainer < uncalibratedMeasurementContainers.size(); ++icontainer) {
185 measurementIndex.addMeasurements(*uncalibratedMeasurementContainers[icontainer]);
186 }
187
188 detail::TrackFindingMeasurements measurements(uncalibratedMeasurementContainers.size());
189 for (std::size_t icontainer = 0; icontainer < uncalibratedMeasurementContainers.size(); ++icontainer) {
190 ATH_MSG_DEBUG("Create " << uncalibratedMeasurementContainers[icontainer]->size() << " source links from measurements in " << m_uncalibratedMeasurementContainerKeys[icontainer].key());
191 measurements.addMeasurements(icontainer,
192 *uncalibratedMeasurementContainers[icontainer],
193 *m_trackingGeometrySvc->surfaceIdMap(),
194 m_forceTrackOnSeed ? &measurementIndex : nullptr);
195 }
196
197 ATH_MSG_DEBUG("measurement index size = " << measurementIndex.size());
198
199 ATH_CHECK( propagateDetectorElementStatusToMeasurements(*(volumeIdToDetectorElementCollMap.cptr()), det_el_status_arr, measurements) );
200
201 if (m_trackStatePrinter.isSet()) {
202 m_trackStatePrinter->printMeasurements(ctx, uncalibratedMeasurementContainers, measurements.measurementOffsets());
203 }
204
205 detail::DuplicateSeedDetector duplicateSeedDetector(total_seeds,
206 m_seedMeasOffset.value(),
208 for (std::size_t icontainer = 0; icontainer < seedContainers.size(); ++icontainer)
209 {
210 duplicateSeedDetector.addSeeds(icontainer, *seedContainers[icontainer], measurementIndex,
211 m_paramEstimationTool[icontainer]->spacePointIndicesFun(),
212 [this,icontainer](const ActsTrk::Seed& seed) -> bool {
213 const bool reverseSearch = m_autoReverseSearch && shouldReverseSearch(seed);
214 return m_paramEstimationTool[icontainer]->estimateFromTopSp(reverseSearch);
215 });
216 }
217
218 // Get Beam pos and make pSurface
220 ATH_CHECK( beamSpotHandle.isValid() );
221 const InDet::BeamSpotData* beamSpotData = beamSpotHandle.cptr();
222
223 // Beam Spot Position
224 Acts::Vector3 beamPos( beamSpotData->beamPos().x() * Acts::UnitConstants::mm,
225 beamSpotData->beamPos().y() * Acts::UnitConstants::mm,
226 0 );
227
228 // Construct a perigee surface as the target surface
229 std::shared_ptr<Acts::PerigeeSurface> pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(beamPos);
230
231 // ================================================== //
232 // ===================== CONDS ====================== //
233 // ================================================== //
234
235
236 // ================================================== //
237 // ===================== COMPUTATION ================ //
238 // ================================================== //
239 Acts::VectorTrackContainer actsTrackBackend;
240 Acts::VectorMultiTrajectory actsTrackStateBackend;
241 {
242 std::lock_guard<std::mutex> lock( m_mutex );
243 actsTrackBackend.reserve(m_nTrackReserve);
244 actsTrackStateBackend.reserve(m_nTrackStateReserve);
245 }
246 detail::RecoTrackContainer actsTracksContainer(actsTrackBackend,
247 actsTrackStateBackend);
248
249 addCountsAndProperties(actsTracksContainer, m_addCounts.value());
250
251 detail::ExpectedLayerPatternHelper::add(actsTracksContainer);
252
253 EventStats event_stat;
254 event_stat.resize(m_stat.size());
255
256 DetectorContextHolder detContext {
257 .geometry = m_ctxProvider.getGeometryContext(ctx),
258 .magField = m_ctxProvider.getMagneticFieldContext(ctx),
259 // CalibrationContext converter not implemented yet.
260 .calib = m_ctxProvider.getCalibrationContext(ctx)
261 };
262
263 detail::SharedHitCounter sharedHits;
264 std::optional<std::vector<unsigned int>> trackCategories;
265 if (m_ambi) trackCategories.emplace(); // only needed if m_ambiStrategy == END_OF_TF
266
267 // Perform the track finding for all initial parameters.
268 for (std::size_t icontainer = 0; icontainer < seedContainers.size(); ++icontainer)
269 {
271 detContext,
272 measurements,
273 measurementIndex,
274 sharedHits,
275 duplicateSeedDetector,
276 *seedContainers.at(icontainer),
277 actsTracksContainer,
278 icontainer,
279 icontainer < m_seedLabels.size() ? m_seedLabels[icontainer].c_str() : m_seedContainerKeys[icontainer].key().c_str(),
280 event_stat,
281 m_storeDestinies ? destinies.at(icontainer).get() : nullptr,
282 *pSurface.get(),
283 trackCategories));
284 }
285
286 ATH_MSG_DEBUG(" \\__ Created " << actsTracksContainer.size() << " tracks");
287
288 mon_nTracks = actsTracksContainer.size();
289
290
291 // ================================================== //
292 // ===================== OUTPUTS ==================== //
293 // ================================================== //
294
295 // Save the seed destinies
296 if (m_storeDestinies) {
297 for (std::size_t i(0); i<destinies.size(); ++i) {
298 const SG::WriteHandleKey< std::vector<int> >& writeKey = m_seedDestiny.at(i);
299 // make the handle and record
300 SG::WriteHandle< std::vector<int> > destinyHandle = SG::makeHandle( writeKey, ctx );
301 ATH_CHECK( destinyHandle.record( std::move( destinies.at(i) ) ) );
302 }
303 }
304
305 {
306 std::lock_guard<std::mutex> lock( m_mutex );
307 // update the reserve space
308 if (actsTrackBackend.size() > m_nTrackReserve) {
309 m_nTrackReserve = static_cast<std::size_t>( std::ceil(m_memorySafetyMargin * actsTrackBackend.size()) );
310 }
311 if (actsTrackStateBackend.size() > m_nTrackStateReserve) {
312 m_nTrackStateReserve = static_cast<std::size_t>( std::ceil(m_memorySafetyMargin * actsTrackStateBackend.size()) );
313 }
314 }
315
316 // handle the ambiguity
317 // we potentially need to short list the track candidates and make some copies
318 if (not m_ambi) {
319 copyStats(event_stat);
320 // no need to shortlist anything. just use the actsTracksContainer
321 ATH_MSG_DEBUG(" \\__ Created " << actsTracksContainer.size() << " resolved tracks");
323 std::move(actsTrackBackend),
324 std::move(actsTrackStateBackend) ) );
325 return StatusCode::SUCCESS;
326 }
327
328 // we have asked for the ambi
329 // we start by shortlisting the container
330 Acts::VectorTrackContainer resolvedTrackBackend;
331 Acts::VectorMultiTrajectory resolvedTrackStateBackend;
332 resolvedTrackBackend.reserve( actsTrackBackend.size() );
333 resolvedTrackStateBackend.reserve( actsTrackStateBackend.size() );
334 detail::RecoTrackContainer resolvedTracksContainer(resolvedTrackBackend, resolvedTrackStateBackend);
335 detail::ExpectedLayerPatternHelper::add(resolvedTracksContainer);
336
337 addCountsAndProperties(resolvedTracksContainer, m_addCounts.value());
338
339 // Start ambiguity resolution
340 Acts::GreedyAmbiguityResolution::State state;
341 m_ambi->computeInitialState(actsTracksContainer, state, &detail::sourceLinkHash,
343 m_ambi->resolve(state);
344
345 // Copy the resolved tracks into the output container
346 // We need a different sharedHits counter here because it saves the track index
347 // and since I ran the resolving the track indices changed.
348 detail::SharedHitCounter sharedHits_forFinalAmbi;
349
350 // shotlist
351 for (auto iTrack : state.selectedTracks) {
352 int actsTrackIndex = state.trackTips.at(iTrack);
353 auto destProxy = resolvedTracksContainer.makeTrack();
354 destProxy.copyFrom(actsTracksContainer.getTrack(actsTrackIndex));
355
356 unsigned int category_i = trackCategories->at(actsTrackIndex);
357 ++event_stat[category_i][kNResolvedTracks];
358
359 if (m_countSharedHits) {
360 auto [nShared, nBadTrackMeasurements] = sharedHits_forFinalAmbi.computeSharedHits(destProxy, resolvedTracksContainer, measurementIndex);
361 if (nBadTrackMeasurements > 0)
362 ATH_MSG_ERROR("computeSharedHits: " << nBadTrackMeasurements << " track measurements not found in input track");
363 }
364 } // loop on tracks
365
366 ATH_MSG_DEBUG(" \\__ Created " << resolvedTracksContainer.size() << " resolved tracks");
367 copyStats(event_stat);
368
370 std::move(resolvedTrackBackend),
371 std::move(resolvedTrackStateBackend)) );
372
373 return StatusCode::SUCCESS;
374 }
375
376 StatusCode TrackFindingAlg::storeTrackCollectionToStoreGate(const EventContext& ctx,
377 Acts::VectorTrackContainer&& originalTrackBackend,
378 Acts::VectorMultiTrajectory&& originalTrackStateBackend) const
379 {
380 // convert to const
381 Acts::ConstVectorTrackContainer constTrackBackend( std::move(originalTrackBackend) );
382 Acts::ConstVectorMultiTrajectory constTrackStateBackend( std::move(originalTrackStateBackend) );
383 std::unique_ptr< ActsTrk::TrackContainer> constTracksContainer = std::make_unique< ActsTrk::TrackContainer >( std::move(constTrackBackend),
384 std::move(constTrackStateBackend) );
385
387 ATH_MSG_DEBUG(" \\__ Tracks Container `" << m_trackContainerKey.key() << "` created ...");
388 ATH_CHECK(trackContainerHandle.record(std::move(constTracksContainer)));
389 return StatusCode::SUCCESS;
390 }
391
393 const xAOD::SpacePoint* bottom_sp = seed.sp().front();
394
395 const double r = bottom_sp->radius();
396 const double z = std::abs(bottom_sp->z());
397
398 const double rBoundary = m_useTopSpRZboundary.value()[0];
399 const double zBoundary = m_useTopSpRZboundary.value()[1];
400
401 return r > rBoundary || z > zBoundary;
402 }
403
404 // === findTracks ==========================================================
405
406 StatusCode
407 TrackFindingAlg::findTracks(const EventContext &ctx,
408 const DetectorContextHolder& detContext,
409 const detail::TrackFindingMeasurements &measurements,
410 const detail::MeasurementIndex &measurementIndex,
411 detail::SharedHitCounter &sharedHits,
412 detail::DuplicateSeedDetector &duplicateSeedDetector,
413 const ActsTrk::SeedContainer &seeds,
414 detail::RecoTrackContainer &actsTracksContainer,
415 std::size_t typeIndex,
416 const char *seedType,
417 EventStats &event_stat,
418 std::vector<int>* destiny,
419 const Acts::PerigeeSurface& pSurface,
420 std::optional<std::vector<unsigned int>>& trackCategories) const
421 {
422 ATH_MSG_DEBUG(name() << "::" << __FUNCTION__);
423
424 auto [options, secondOptions, measurementSelector] = getDefaultOptions(ctx, detContext, measurements, &pSurface);
425
426 // ActsTrk::MutableTrackContainer tracksContainerTemp;
427 Acts::VectorTrackContainer trackBackend;
428 Acts::VectorMultiTrajectory trackStateBackend;
429 detail::RecoTrackContainer tracksContainerTemp(trackBackend, trackStateBackend);
430
431 addCountsAndProperties(tracksContainerTemp, m_addCounts.value());
432
433 detail::ExpectedLayerPatternHelper::add(tracksContainerTemp);
434
435 std::size_t category_i = 0;
436 const auto &trackSelectorCfg = trackFinder().trackSelector.config();
437 auto stopBranchProxy = [&](const detail::RecoTrackContainer::TrackProxy &track,
438 const detail::RecoTrackContainer::TrackStateProxy &trackState) -> BranchStopperResult {
439 return stopBranch(track, trackState, trackSelectorCfg, detContext.geometry, measurementIndex, typeIndex, event_stat[category_i]);
440 };
441 options.extensions.branchStopper.connect(stopBranchProxy);
442
443 Acts::PropagatorOptions<detail::Stepper::Options, detail::Navigator::Options,
444 Acts::ActorList<Acts::MaterialInteractor>>
445 extrapolationOptions(detContext.geometry, detContext.magField);
446
447 Acts::TrackExtrapolationStrategy extrapolationStrategy =
448 Acts::TrackExtrapolationStrategy::first;
449
450 // Perform the track finding for all initial parameters
451 ATH_MSG_DEBUG("Invoke track finding with " << seeds.size() << ' ' << seedType << " seeds.");
452
453
454 std::size_t nPrinted = 0;
455
456 // Function for Estimate Track Parameters
457 auto retrieveSurfaceFunction =
458 [detectorElementToGeometryIdMapPtr=m_trackingGeometrySvc->surfaceIdMap(),
459 actsTrackingGeometryPtr=m_trackingGeometrySvc->trackingGeometry().get()] (const ActsTrk::Seed& seed, bool useTopSp) -> const Acts::Surface& {
460 const xAOD::SpacePoint* sp = useTopSp ? seed.sp().back() : seed.sp().front();
461 const xAOD::UncalibratedMeasurement* meas = useTopSp ? sp->measurements().back() : sp->measurements().front();
462 const auto geoid_iter = detectorElementToGeometryIdMapPtr->find(ActsTrk::makeDetectorElementKey(meas->type(), meas->identifierHash()));
463 if (geoid_iter == detectorElementToGeometryIdMapPtr->end()) {
464 throw std::runtime_error("measurement not linked to Acts surface.");
465 }
466 const Acts::Surface *surface = DetectorElementToActsGeometryIdMap::getSurface(*geoid_iter);
467 if (surface == nullptr) {
468 surface = actsTrackingGeometryPtr->findSurface( DetectorElementToActsGeometryIdMap::getValue(*geoid_iter) );
469 }
470 assert(surface);
471 return *surface;
472 };
473
474
475
476 // Loop over the track finding results for all initial parameters
477 for (unsigned int iseed = 0; iseed < seeds.size(); ++iseed)
478 {
479 // Get the seed
480 const ActsTrk::Seed seed = seeds[iseed];
481
482 category_i = typeIndex * (m_statEtaBins.size() + 1);
483 tracksContainerTemp.clear();
484
485 const bool reverseSearch = m_autoReverseSearch && shouldReverseSearch(seed);
486
487 // Check if the seed is a duplicate seed
488 const bool isDupSeed = duplicateSeedDetector.isDuplicate(typeIndex, iseed);
489 if (isDupSeed) {
490 ATH_MSG_DEBUG("skip " << seedType << " seed " << iseed << " - already found");
491 category_i = getSeedCategory(typeIndex, seed, m_paramEstimationTool[typeIndex]->estimateFromTopSp(reverseSearch));
492 ++event_stat[category_i][kNTotalSeeds];
493 ++event_stat[category_i][kNDuplicateSeeds];
494 if (m_storeDestinies) destiny->at(iseed) = DestinyType::DUPLICATE;
495 if (!m_trackStatePrinter.isSet()) continue; // delay continue to estimate track parms for TrackStatePrinter?
496 }
497
498 // Get first estimate of parameters from the seed
499 const auto& [optTrackParams, estimationStatus] =
500 m_paramEstimationTool[typeIndex]->estimateTrackParameters(seed,
501 reverseSearch,
502 detContext.geometry,
503 detContext.magField,
504 detContext.calib,
505 retrieveSurfaceFunction);
506
507 if (!optTrackParams) {
508 ATH_MSG_DEBUG("Failed to estimate track parameters for seed " << iseed);
509 if (!isDupSeed) {
510 category_i = getSeedCategory(typeIndex, seed, m_paramEstimationTool[typeIndex]->estimateFromTopSp(reverseSearch));
511 ++event_stat[category_i][kNTotalSeeds];
512 ++event_stat[category_i][kNNoEstimatedParams];
513 if (m_storeDestinies) destiny->at(iseed) = DestinyType::FAILURE;
514 }
515 continue;
516 }
517
518 printSeed(iseed, detContext, seeds, *optTrackParams, measurementIndex, nPrinted, seedType);
519 if (isDupSeed) continue; // skip now if not done before
520
521 double etaInitial = -std::log(std::tan(0.5 * optTrackParams->theta()));
522 category_i = getStatCategory(typeIndex, etaInitial);
523 ++event_stat[category_i][kNTotalSeeds]; // also updated for duplicate seeds
524 ++event_stat[category_i][kNUsedSeeds];
525
526 if (estimationStatus != ITrackParamsEstimationTool::kNoSeedRefit) {
527 if (estimationStatus == ITrackParamsEstimationTool::kSeedRefitFailed) {
528 ++event_stat[category_i][kNSeedRefitFailure];
529 } else {
530 // Check pTmin requirement
531 const auto &cutSet = getCuts(etaInitial);
532 if (optTrackParams->transverseMomentum() < cutSet.ptMin * m_seedRefitPtMinFactor) {
533 ATH_MSG_VERBOSE("min pt requirement not satisfied after param refinement: pt min is " << cutSet.ptMin << " but Refined params have pt of " << optTrackParams->transverseMomentum());
534 ++event_stat[category_i][kNRejectedRefinedSeeds];
535 if (m_storeDestinies) destiny->at(iseed) = DestinyType::FAILURE;
536 continue;
537 }
538 }
539 }
540
541 // Set the option accordingly - we change the direction and the target surface accordingly
542 options.propagatorPlainOptions.direction = reverseSearch ? Acts::Direction::Backward() : Acts::Direction::Forward();
543 secondOptions.propagatorPlainOptions.direction = options.propagatorPlainOptions.direction.invert();
544 options.targetSurface = reverseSearch ? &pSurface : nullptr;
545 secondOptions.targetSurface = reverseSearch ? nullptr : &pSurface;
546 // TODO since the second pass is strictly an extension we should have a separate branch stopper which never drops and always extrapolates to the target surface
547
548 xAOD::TrackFitter current_fitter = xAOD::KalmanFitter;
549 // @TODO introduce additional enums to distinguish Acts CKF from other implementations?
550
551 auto measurementRangesForced =
552 m_forceTrackOnSeed ? measurements.createMeasurementRangesForced(seed, measurementIndex)
553 : std::unique_ptr<ActsTrk::detail::MeasurementRangeListFlat>();
554 measurementSelector->setMeasurementRangesForced(measurementRangesForced.get());
555 if (measurementRangesForced)
556 event_stat[category_i][kNForcedSeedMeasurements] += measurementRangesForced->size();
557
558 // Get the Acts tracks, given this seed
559 Acts::Result<std::vector<TrkProxy> > result =
560 trackFinder().ckf.findTracks(*optTrackParams, options, tracksContainerTemp);
561
562 // The result for this seed
563 if (not result.ok()) {
564 ATH_MSG_WARNING("Track finding failed for " << seedType << " seed " << iseed << " with error" << result.error());
565 if (m_storeDestinies) destiny->at(iseed) = DestinyType::FAILURE;
566 continue;
567 }
568 auto &tracksForSeed = result.value();
569
570
571
572 std::size_t ntracks = 0ul;
573
574 // loop on the tracks we have just found from the seed
575 std::size_t nfirst = 0;
576 for (TrkProxy &firstTrack : tracksForSeed) {
577 ActsTrk::TrackContainerUtils::setFitterType(firstTrack,current_fitter);
578 // smoothing
579 auto smoothingResult = Acts::smoothTrack(detContext.geometry, firstTrack, logger(), Acts::MbfSmoother());
580 if (!smoothingResult.ok()) {
581 ATH_MSG_DEBUG("Smoothing for seed "
582 << iseed << " and first track " << firstTrack.index()
583 << " failed with error " << smoothingResult.error());
584 continue;
585 }
586
587 // if no two way, just add the track and move on
588 if (not m_doTwoWay) {
589 // add the track to the collection
590 ATH_CHECK( addTrack(detContext,
591 firstTrack,
592 pSurface,
593 extrapolationStrategy,
594 sharedHits,
595 actsTracksContainer,
596 measurementIndex,
597 tracksContainerTemp,
598 duplicateSeedDetector,
599 destiny,
600 event_stat,
601 ntracks,
602 iseed,
603 category_i,
604 seedType,
605 trackCategories) );
606 ++nfirst;
607 continue;
608 }
609
610 // TWO WAY STARTS HERE
611 // We need the first measurement of the track
612 std::optional<detail::RecoTrackStateContainerProxy> firstMeas = getFirstMeasurementFromTrack(firstTrack);
613 // we are supposed to find a measurement
614 if (not firstMeas.has_value()) {
615 ATH_MSG_ERROR("Could not retrieve first measurement from track proxy. Is it ill-formed?");
616 return StatusCode::FAILURE;
617 }
618 detail::RecoTrackStateContainerProxy& firstMeasurement = firstMeas.value();
619
620 // Get the tracks from the second track finding
621 std::vector<typename detail::RecoTrackContainer::TrackProxy> secondTracksForSeed =
622 doTwoWayTrackFinding(firstMeasurement,
623 firstTrack,
624 tracksContainerTemp,
625 secondOptions);
626
627 if ( secondTracksForSeed.empty() ) {
628 ATH_MSG_DEBUG("No viable result from second track finding for " << seedType << " seed " << iseed << " track " << nfirst);
629 ++event_stat[category_i][kNoSecond];
630 ATH_CHECK( addTrack(detContext,
631 firstTrack,
632 pSurface,
633 extrapolationStrategy,
634 sharedHits,
635 actsTracksContainer,
636 measurementIndex,
637 tracksContainerTemp,
638 duplicateSeedDetector,
639 destiny,
640 event_stat,
641 ntracks,
642 iseed,
643 category_i,
644 seedType,
645 trackCategories) );
646 }
647
648 // need to add tracks here
649 // do the stiching
650 // store the original previous state to restore it later
651 auto originalFirstMeasurementPrevious = firstMeasurement.previous();
652 for (auto &secondTrack : secondTracksForSeed) {
653 secondTrack.reverseTrackStates(true);
654
655 firstMeasurement.previous() = secondTrack.outermostTrackState().index();
656 secondTrack.tipIndex() = firstTrack.tipIndex();
657
658 if (reverseSearch) {
659 // smooth the full track
660 auto secondSmoothingResult = Acts::smoothTrack(detContext.geometry,
661 secondTrack,
662 logger());
663 if ( not secondSmoothingResult.ok() ) {
664 continue;
665 }
666 secondTrack.reverseTrackStates(true);
667 }
668
669 // Add track to collection
670 ATH_CHECK( addTrack(detContext,
671 secondTrack,
672 pSurface,
673 extrapolationStrategy,
674 sharedHits,
675 actsTracksContainer,
676 measurementIndex,
677 tracksContainerTemp,
678 duplicateSeedDetector,
679 destiny,
680 event_stat,
681 ntracks,
682 iseed,
683 category_i,
684 seedType,
685 trackCategories) );
686 } // loop on tracks
687
688 // finish the stiching
689 // restore the original previous state for the first track
690 firstMeasurement.previous() = originalFirstMeasurementPrevious;
691
692 nfirst++;
693 } // loop on tracks from seed
694
695 if (m_storeDestinies) {
696 if (ntracks == 0) {
697 destiny->at(iseed) = DestinyType::FAILURE;
698 } else {
699 destiny->at(iseed) = DestinyType::SUCCEED;
700 }
701 }
702
703 if (ntracks == 0) {
704 ATH_MSG_DEBUG("Track finding found no track candidates for " << seedType << " seed " << iseed);
705 ++event_stat[category_i][kNoTrack];
706 } else if (ntracks >= 2) {
707 ++event_stat[category_i][kMultipleBranches];
708 }
709
710 if (m_trackStatePrinter.isSet())
711 std::cout << std::flush;
712 } // loop on seeds
713
714 ATH_MSG_DEBUG("Completed " << seedType << " track finding with " << computeStatSum(typeIndex, kNOutputTracks, event_stat) << " track candidates.");
715
716 return StatusCode::SUCCESS;
717 }
718
719 void
722 detail::DuplicateSeedDetector &duplicateSeedDetector,
723 const detail::MeasurementIndex &measurementIndex) const {
724
725 const auto lastMeasurementIndex = track.tipIndex();
726 duplicateSeedDetector.newTrajectory();
727
728 tracksContainer.trackStateContainer().visitBackwards(
729 lastMeasurementIndex,
730 [&duplicateSeedDetector,&measurementIndex](const detail::RecoTrackStateContainer::ConstTrackStateProxy &state) -> void
731 {
732 // Check there is a source link
733 if (not state.hasUncalibratedSourceLink())
734 return;
735
736 // Fill the duplicate selector
737 auto sl = detail::xAODUncalibMeasCalibrator::unpack(state.getUncalibratedSourceLink());;
738 duplicateSeedDetector.addMeasurement(sl, measurementIndex);
739 }); // end visitBackwards
740 }
741
743 const std::vector< const InDet::SiDetectorElementStatus *> &det_el_status_arr,
744 detail::TrackFindingMeasurements &measurements) const {
745 const Acts::TrackingGeometry *
746 acts_tracking_geometry = m_trackingGeometrySvc->trackingGeometry().get();
747 ATH_CHECK(acts_tracking_geometry != nullptr);
748
749 using Counter = struct { unsigned int n_volumes, n_volumes_with_status, n_missing_detector_elements, n_detector_elements, n_disabled_detector_elements;};
750 Counter counter {0u,0u,0u,0u,0u};
751 acts_tracking_geometry->visitVolumes([&counter,
752 &volume_id_to_det_el_coll,
753 &det_el_status_arr,
754 &measurements,
755 this](const Acts::TrackingVolume *volume_ptr) {
756 ++counter.n_volumes;
757 if (!volume_ptr) return;
758
760 det_el_status = det_el_status_arr.at(volume_id_to_det_el_coll.collecionMap().at(volume_ptr->geometryId().volume()));
761 if (det_el_status) {
762 ++counter.n_volumes_with_status;
763 volume_ptr->visitSurfaces([&counter, det_el_status, &measurements,this](const Acts::Surface *surface_ptr) {
764
765 const auto* acts_detector_element = getActsDetectorElement(surface_ptr);
766 if (!acts_detector_element) {
767 return;
768 }
769 ++counter.n_detector_elements;
770
771 if (!det_el_status->isGood( acts_detector_element->identifyHash() )) {
772 ActsTrk::detail::MeasurementRange old_range = measurements.markSurfaceInsensitive(surface_ptr->geometryId());
773 if (!old_range.empty()) {
774 auto geoid_to_string = [](const Acts::GeometryIdentifier &id) -> std::string {
775 std::stringstream amsg;
776 amsg << id;
777 return amsg.str();
778 };
779 std::string a_msg ( geoid_to_string(surface_ptr->geometryId()));
780 ATH_MSG_WARNING("Reject " << (old_range.elementEndIndex() - old_range.elementBeginIndex())
781 << " measurements because surface " << a_msg);
782 }
783 ++counter.n_disabled_detector_elements;
784 }
785
786 }, true /*only sensitive surfaces*/);
787 }
788 else {
789 ++counter.n_missing_detector_elements;
790 }
791 });
792 ATH_MSG_DEBUG("Volumes with detector element status " << counter.n_volumes_with_status << " / " << counter.n_volumes
793 << " disabled detector elements " << counter.n_disabled_detector_elements
794 << " / " << counter.n_detector_elements
795 << " missing detector elements "
796 << counter.n_missing_detector_elements);
797 return StatusCode::SUCCESS;
798 }
799
800 std::size_t TrackFindingAlg::getSeedCategory(std::size_t typeIndex,
801 const ActsTrk::Seed& seed,
802 bool useTopSp) const
803 {
804 const xAOD::SpacePoint* sp = useTopSp ? seed.sp().back() : seed.sp().front();
805 const xAOD::SpacePoint::ConstVectorMap pos = sp->globalPosition();
806 double etaSeed = std::atanh(pos[2] / pos.norm());
807 return getStatCategory(typeIndex, etaSeed);
808 }
809
810 void TrackFindingAlg::printSeed(unsigned int iseed,
811 const DetectorContextHolder& detContext,
812 const ActsTrk::SeedContainer& seeds,
813 const Acts::BoundTrackParameters &seedParameters,
814 const detail::MeasurementIndex &measurementIndex,
815 std::size_t& nPrinted,
816 const char *seedType,
817 bool isKF) const
818 {
819 if (not m_trackStatePrinter.isSet()) return;
820
821 if (nPrinted == 0) {
822 ATH_MSG_INFO("CKF results for " << seeds.size() << ' ' << seedType << " seeds:");
823 }
824 ++nPrinted;
825 m_trackStatePrinter->printSeed(detContext.geometry, seeds[iseed], seedParameters, measurementIndex, iseed, isKF);
826 }
827
828namespace {
829struct Collector {
830 using result_type = TrackFindingAlg::ExpectedLayerPattern*;
831
832 template <typename propagator_state_t, typename stepper_t,
833 typename navigator_t>
834 Acts::Result<void> act(propagator_state_t& state, const stepper_t& /*stepper*/,
835 const navigator_t& navigator, result_type& result,
836 const Acts::Logger& /*logger*/) const {
837 const Acts::Surface* currentSurface = navigator.currentSurface(state.navigation);
838 if (currentSurface == nullptr) {
839 return Acts::Result<void>::success();
840 }
841
842 assert(result != nullptr && "Result type is nullptr");
843 const auto* detElem = getActsDetectorElement(currentSurface);
844 if(detElem != nullptr) {
845 detail::addToExpectedLayerPattern(*result, *detElem);
846 }
847
848
849 return Acts::Result<void>::success();
850 }
851};
852}
853
855 const DetectorContextHolder& detContext,
857 const Acts::Surface &referenceSurface,
858 const detail::Extrapolator &propagator,
859 Acts::TrackExtrapolationStrategy strategy,
860 ExpectedLayerPattern& expectedLayerPattern) const {
861
862 Acts::PropagatorOptions<detail::Stepper::Options, detail::Navigator::Options,
863 Acts::ActorList<Acts::MaterialInteractor, Collector>>
864 options(detContext.geometry, detContext.magField);
865
866 auto findResult = findTrackStateForExtrapolation(
867 options.geoContext, track, referenceSurface, strategy, logger());
868
869 if (!findResult.ok()) {
870 ATH_MSG_WARNING("Failed to find track state for extrapolation");
871 return findResult.error();
872 }
873
874 auto &[trackState, distance] = *findResult;
875
876 options.direction = Acts::Direction::fromScalarZeroAsPositive(distance);
877
878 Acts::BoundTrackParameters parameters = track.createParametersFromState(trackState);
879 ATH_MSG_VERBOSE("Extrapolating track to reference surface at distance "
880 << distance << " with direction " << options.direction
881 << " with starting parameters " << parameters);
882
883 auto state = propagator.makeState<decltype(options), Acts::ForcedSurfaceReached>(referenceSurface, options);
884 ExpectedLayerPattern*& collectorResult = state.get<TrackFindingAlg::ExpectedLayerPattern*>();
885 collectorResult = &expectedLayerPattern;
886
887 auto initRes = propagator.initialize(state, parameters);
888 if(!initRes.ok()) {
889 ATH_MSG_WARNING("Failed to initialize propagation state: " << initRes.error().message());
890 return initRes.error();
891 }
892
893
894 auto propagateOnlyResult =
895 propagator.propagate(state);
896
897 if (!propagateOnlyResult.ok()) {
898 ATH_MSG_WARNING("Failed to extrapolate track: " << propagateOnlyResult.error().message());
899 return propagateOnlyResult.error();
900 }
901
902 auto propagateResult = propagator.makeResult(
903 std::move(state), propagateOnlyResult, options, true, &referenceSurface);
904
905 if (!propagateResult.ok()) {
906 ATH_MSG_WARNING("Failed to extrapolate track: " << propagateResult.error().message());
907 return propagateResult.error();
908 }
909
910 track.setReferenceSurface(referenceSurface.getSharedPtr());
911 track.parameters() = propagateResult->endParameters.value().parameters();
912 track.covariance() =
913 propagateResult->endParameters.value().covariance().value();
914
915 return Acts::Result<void>::success();
916 }
917
920 const Acts::Surface& pSurface,
921 const Acts::TrackExtrapolationStrategy& extrapolationStrategy,
922 detail::SharedHitCounter &sharedHits,
923 detail::RecoTrackContainer &actsTracksContainer,
924 const detail::MeasurementIndex& measurementIndex,
925 const detail::RecoTrackContainer& tracksContainerTemp,
926 detail::DuplicateSeedDetector& duplicateSeedDetector,
927 std::vector<int>* destiny,
928 EventStats& event_stat,
929 std::size_t& ntracks,
930 std::size_t iseed,
931 std::size_t category_i,
932 const char *seedType,
933 std::optional<std::vector<unsigned int>>& trackCategories) const
934 {
935
936 std::array<unsigned int, 4> expectedLayerPattern{};
937
938 // if the the perigeeSurface was not hit (in particular the case for the inside-out pass,
939 // the track has no reference surface and the extrapolation to the perigee has not been done
940 // yet.
941 if (not track.hasReferenceSurface()) {
942 auto extrapolationResult =
943 extrapolateTrackToReferenceSurface(detContext, track,
944 pSurface,
945 trackFinder().extrapolator,
946 extrapolationStrategy,
947 expectedLayerPattern);
948
949 if (not extrapolationResult.ok()) {
950 ATH_MSG_WARNING("Extrapolation for seed "
951 << iseed << " and " << track.index()
952 << " failed with error " << extrapolationResult.error()
953 << " dropping track candidate.");
954 if (m_storeDestinies) destiny->at(iseed) = DestinyType::FAILURE;
955 return StatusCode::SUCCESS;
956 }
957 }
958
959 // Before trimming, inspect encountered surfaces from all track states
960 for(const auto ts : track.trackStatesReversed()) {
961 const auto* detElem = getActsDetectorElement(ts.referenceSurface());
962 if(detElem != nullptr) {
963 detail::addToExpectedLayerPattern(expectedLayerPattern, *detElem);
964 }
965 }
966
967 // Trim tracks
968 // - trimHoles
969 // - trimOutliers
970 // - trimMaterial
971 // - trimOtherNoneMeasurement
972 Acts::trimTrack(track, true, true, true, true);
973 Acts::calculateTrackQuantities(track);
974 if (m_addCounts) {
975 initCounts(track);
976 for (const auto trackState : track.trackStatesReversed()) {
977 updateCounts(track, trackState.typeFlags(), measurementType(trackState));
978 }
979 if (m_checkCounts) {
980 checkCounts(track);
981 }
982 }
983
984 ++ntracks;
985 ++event_stat[category_i][kNOutputTracks];
986
987 if ( not trackFinder().trackSelector.isValidTrack(track) or
988 not selectCountsFinal(track)) {
989 ATH_MSG_DEBUG("Track " << ntracks << " from " << seedType << " seed " << iseed << " failed track selection");
990 if ( m_trackStatePrinter.isSet() ) {
991 m_trackStatePrinter->printTrack(detContext.geometry, tracksContainerTemp, track, measurementIndex, true);
992 }
993 return StatusCode::SUCCESS;
994 }
995
996 ++event_stat[category_i][kNSelectedTracks];
997
998 // Fill the track infos into the duplicate seed detector
1000 storeSeedInfo(tracksContainerTemp, track, duplicateSeedDetector, measurementIndex);
1001 }
1002
1003 auto actsDestProxy = actsTracksContainer.makeTrack();
1004 actsDestProxy.copyFrom(track); // make sure we copy track states!
1005
1006 detail::ExpectedLayerPatternHelper::set(actsDestProxy, expectedLayerPattern);
1007
1008 auto setTrackCategory = [&]() {
1009 if (!trackCategories) return;
1010 if (!(actsDestProxy.index() < trackCategories->size())) trackCategories->resize(actsDestProxy.index()+1);
1011 trackCategories->at(actsDestProxy.index()) = category_i;
1012 };
1013
1014 if (not m_countSharedHits) {
1015 return StatusCode::SUCCESS;
1016 }
1017
1018 auto [nShared, nBadTrackMeasurements] = sharedHits.computeSharedHits(actsDestProxy, actsTracksContainer, measurementIndex);
1019
1020 if (nBadTrackMeasurements > 0) {
1021 ATH_MSG_ERROR("computeSharedHits: " << nBadTrackMeasurements << " track measurements not found in input for " << seedType << " seed " << iseed << " track");
1022 }
1023
1024 ATH_MSG_DEBUG("found " << actsDestProxy.nSharedHits() << " shared hits in " << seedType << " seed " << iseed << " track");
1025
1026 event_stat[category_i][kNTotalSharedHits] += nShared;
1027
1028 if (m_ambiStrategy == 2u) { // run the ambiguity during track selection
1029
1030 if (actsDestProxy.nSharedHits() <= m_maximumSharedHits) {
1031 setTrackCategory();
1032 ++event_stat[category_i][kNResolvedTracks];
1033 }
1034 else { // track fails the shared hit selection
1035
1036 ATH_MSG_DEBUG("found " << actsDestProxy.nSharedHits() << " shared hits in " << seedType << " seed " << iseed << " track");
1037 // Reset the original track shared hits by running coumputeSharedHits
1038 // with removeSharedHits flag to true
1039 // nSharedRemoved contains the total shared hits that will be removed
1040 auto [nSharedRemoved, nRemoveBadTrackMeasurements] = sharedHits.computeSharedHits(actsDestProxy, actsTracksContainer, measurementIndex, true);
1041
1042 ATH_MSG_DEBUG("Removed " << nSharedRemoved << " shared hits in " << seedType << " seed " << iseed << " track and the matching track");
1043
1044 if (nRemoveBadTrackMeasurements > 0) {
1045 ATH_MSG_ERROR("computeSharedHits with remove flag ON: " << nRemoveBadTrackMeasurements <<
1046 " track measurements not found in input for " << seedType << " seed " << iseed << " track");
1047 }
1048
1049 if (actsDestProxy.nSharedHits() != 0) {
1050 ATH_MSG_ERROR("computeSharedHits with remove flag ON returned " <<
1051 actsDestProxy.nSharedHits()<< " while expecting 0 for" <<
1052 seedType << " seed " << iseed << " track");
1053 }
1054
1055 // Remove the track from the container
1056 actsTracksContainer.removeTrack(actsDestProxy.index());
1057 ATH_MSG_DEBUG("Track " << ntracks << " from " << seedType << " seed " << iseed << " failed shared hit selection");
1058 }
1059 }
1060 else {
1061 // run ambi later
1062 setTrackCategory();
1063 if (m_trackStatePrinter.isSet()) {
1064 m_trackStatePrinter->printTrack(detContext.geometry, actsTracksContainer, actsDestProxy, measurementIndex);
1065 }
1066 }
1067
1068 return StatusCode::SUCCESS;
1069 }
1070
1071} // namespace
const ActsDetectorElement * getActsDetectorElement(const Acts::Surface &surf)
Attempts to retrieve the ActsDetectorElement associated to the passed ActsSurface.
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
static Double_t sp
Header file to be included by clients of the Monitored infrastructure.
size_t size() const
Number of registered mappings.
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Definition Logger.cxx:64
#define z
SG::WriteHandleKeyArray< std::vector< int > > m_seedDestiny
StatusCode findTracks(const EventContext &ctx, const DetectorContextHolder &detContext, const detail::TrackFindingMeasurements &measurements, const detail::MeasurementIndex &measurementIndex, detail::SharedHitCounter &sharedHits, detail::DuplicateSeedDetector &duplicateSeedDetector, const ActsTrk::SeedContainer &seeds, detail::RecoTrackContainer &actsTracksContainer, std::size_t seedCollectionIndex, const char *seedType, EventStats &event_stat, std::vector< int > *destiny, const Acts::PerigeeSurface &pSurface, std::optional< std::vector< unsigned int > > &trackCategories) const
invoke track finding procedure
Gaudi::Property< bool > m_countSharedHits
Gaudi::Property< unsigned int > m_maximumSharedHits
Gaudi::Property< float > m_memorySafetyMargin
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_uncalibratedMeasurementContainerKeys
SG::ReadHandleKeyArray< ActsTrk::SeedContainer > m_seedContainerKeys
std::size_t getSeedCategory(std::size_t typeIndex, const ActsTrk::Seed &seed, bool useTopSp) const
SG::ReadCondHandleKey< ActsTrk::ActsVolumeIdToDetectorElementCollectionMap > m_volumeIdToDetectorElementCollMapKey
TrackFindingAlg(const std::string &name, ISvcLocator *pSvcLocator)
void printSeed(unsigned int iseed, const DetectorContextHolder &detContext, const ActsTrk::SeedContainer &seeds, const Acts::BoundTrackParameters &seedParameters, const detail::MeasurementIndex &measurementIndex, std::size_t &nPrinted, const char *seedType, bool isKF=false) const
void storeSeedInfo(const detail::RecoTrackContainer &tracksContainer, const detail::RecoTrackContainerProxy &track, detail::DuplicateSeedDetector &duplicateSeedDetector, const detail::MeasurementIndex &measurementIndex) const
std::optional< Acts::GreedyAmbiguityResolution > m_ambi
StatusCode propagateDetectorElementStatusToMeasurements(const ActsTrk::ActsVolumeIdToDetectorElementCollectionMap &volume_id_to_det_el_coll, const std::vector< const InDet::SiDetectorElementStatus * > &det_el_status_arr, detail::TrackFindingMeasurements &measurements) const
Gaudi::Property< unsigned int > m_nMeasurementsMin
Gaudi::Property< unsigned int > m_seedMeasOffset
virtual StatusCode initialize() override
Gaudi::Property< std::vector< double > > m_useTopSpRZboundary
Acts::Result< void > extrapolateTrackToReferenceSurface(const DetectorContextHolder &detContext, detail::RecoTrackContainerProxy &track, const Acts::Surface &referenceSurface, const detail::Extrapolator &propagator, Acts::TrackExtrapolationStrategy strategy, ExpectedLayerPattern &expectedLayerPattern) const
Gaudi::Property< bool > m_autoReverseSearch
StatusCode storeTrackCollectionToStoreGate(const EventContext &ctx, Acts::VectorTrackContainer &&originalTrackBackend, Acts::VectorMultiTrajectory &&originalTrackStateBackend) const
Gaudi::Property< unsigned int > m_maximumIterations
std::array< unsigned int, 4 > ExpectedLayerPattern
Gaudi::Property< bool > m_forceTrackOnSeed
Gaudi::Property< bool > m_skipDuplicateSeeds
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
ToolHandleArray< ActsTrk::ITrackParamsEstimationTool > m_paramEstimationTool
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode finalize() override
StatusCode addTrack(const DetectorContextHolder &detContext, detail::RecoTrackContainerProxy &track, const Acts::Surface &pSurface, const Acts::TrackExtrapolationStrategy &extrapolationStrategy, detail::SharedHitCounter &sharedHits, detail::RecoTrackContainer &actsTracksContainer, const detail::MeasurementIndex &measurementIndex, const detail::RecoTrackContainer &tracksContainerTemp, detail::DuplicateSeedDetector &duplicateSeedDetector, std::vector< int > *destiny, EventStats &event_stat, std::size_t &ntracks, std::size_t iseed, std::size_t category_i, const char *seedType, std::optional< std::vector< unsigned int > > &trackCategories) const
Gaudi::Property< std::size_t > m_ambiStrategy
bool shouldReverseSearch(const ActsTrk::Seed &seed) const
SG::ReadHandleKeyArray< InDet::SiDetectorElementStatus > m_detElStatus
Gaudi::Property< std::vector< float > > m_statEtaBins
Gaudi::Property< bool > m_doTwoWay
Gaudi::Property< bool > m_dumpAllStatEtaBins
static xAOD::UncalibMeasType measurementType(const detail::RecoTrackContainer::TrackStateProxy &trackState)
ToolHandle< ActsTrk::TrackStatePrinterTool > m_trackStatePrinter
SG::WriteHandleKey< ActsTrk::TrackContainer > m_trackContainerKey
Gaudi::Property< double > m_seedRefitPtMinFactor
detail::RecoTrackContainer::TrackProxy TrkProxy
void copyStats(const EventStats &event_stat) const
std::size_t getStatCategory(std::size_t seed_collection, float eta) const
ToolHandle< GenericMonitoringTool > m_monTool
std::vector< typename detail::RecoTrackContainer::TrackProxy > doTwoWayTrackFinding(const detail::RecoTrackStateContainerProxy &firstMeasurement, const TrkProxy &trackProxy, detail::RecoTrackContainer &tracksContainerTemp, const TrackFinderOptions &options) const
Perform two-way track finding.
TrackFindingBaseAlg(const std::string &name, ISvcLocator *pSvcLocator)
std::size_t computeStatSum(std::size_t seed_collection, EStat counter_i, const EventStats &stat) const
virtual StatusCode initialize() override
StatusCode getContainersFromKeys(const EventContext &ctx, HandleArrayKeyType &handleKeyArray, std::vector< const ContainerType * > &outputContainers, std::size_t &sum) const
Take the array of handle keys and for each key retrieve containers, then append them to the output ve...
void checkCounts(const detail::RecoTrackContainer::TrackProxy &track) const
static void addCountsAndProperties(detail::RecoTrackContainer &tracksContainer, bool add_counts)
const Acts::Logger & logger() const
Private access to the logger.
BranchStopperResult stopBranch(const detail::RecoTrackContainer::TrackProxy &track, const detail::RecoTrackContainer::TrackStateProxy &trackState, const Acts::TrackSelector::EtaBinnedConfig &trackSelectorCfg, const Acts::GeometryContext &tgContext, const detail::MeasurementIndex &measurementIndex, const std::size_t typeIndex, EventStats::value_type &event_stat_category_i) const
Branch stopper.
static void initCounts(const detail::RecoTrackContainer::TrackProxy &track)
const Acts::TrackSelector::Config & getCuts(double eta) const
Retrieves track selector configuration for given eta value.
Gaudi::Property< bool > m_checkCounts
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
TrackFindingDefaultOptions getDefaultOptions(const EventContext &ctx, const DetectorContextHolder &detContext, const detail::TrackFindingMeasurements &measurements, const Acts::PerigeeSurface *pSurface) const
Get CKF options for first and second pass + pointer to MeasurementSelector.
virtual StatusCode finalize() override
ContextUtility m_ctxProvider
Utility to fetch the geometry, magnetic field and calibration context in the event.
std::vector< std::array< unsigned int, kNStat > > EventStats
static void updateCounts(const detail::RecoTrackContainer::TrackProxy &track, Acts::ConstTrackStateTypeMap typeFlags, xAOD::UncalibMeasType detType)
Gaudi::Property< bool > m_addCounts
Acts::CombinatorialKalmanFilterBranchStopperResult BranchStopperResult
bool selectCountsFinal(const detail::RecoTrackContainer::TrackProxy &track) const
Gaudi::Property< std::vector< std::string > > m_seedLabels
bool isDuplicate(std::size_t typeIndex, index_t iseed)
void addMeasurement(const xAOD::UncalibratedMeasurement *sl, const MeasurementIndex &measurementIndex)
void addSeeds(std::size_t typeIndex, const ActsTrk::SeedContainer &seeds, const MeasurementIndex &measurementIndex)
void addMeasurements(const xAOD::UncalibratedMeasurementContainer &clusterContainer)
auto computeSharedHits(typename track_container_t::TrackProxy &track, track_container_t &tracks, const MeasurementIndex &measurementIndex, bool removeSharedHits=false) -> ReturnSharedAndBad
const std::vector< std::size_t > & measurementOffsets() const
std::unique_ptr< MeasurementRangeListFlat > createMeasurementRangesForced(const ActsTrk::Seed &seed, const MeasurementIndex &measurementIndex) const
void addMeasurements(std::size_t typeIndex, const xAOD::UncalibratedMeasurementContainer &clusterContainer, const DetectorElementToActsGeometryIdMap &detectorElementToGeoid, const MeasurementIndex *measurementIndex=nullptr)
MeasurementRange markSurfaceInsensitive(const Acts::GeometryIdentifier &identifier)
static const xAOD::UncalibratedMeasurement * unpack(const Acts::SourceLink &sl)
Helper method to unpack an Acts source link to an uncalibrated measurement.
const Amg::Vector3D & beamPos() const noexcept
bool isGood(IdentifierHash hash) const
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
A monitored timer.
const_pointer_type cptr()
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
Property holding a SG store/key/clid from which a WriteHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
float z() const
Eigen::Map< const Eigen::Matrix< float, 3, 1 > > ConstVectorMap
float radius() const
DetectorIDHashType identifierHash() const
Returns the IdentifierHash of the measurement (corresponds to the detector element IdentifierHash).
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
int ts
Definition globals.cxx:24
int r
Definition globals.cxx:22
bool sourceLinkEquality(const Acts::SourceLink &a, const Acts::SourceLink &b)
Returns whether two source links are equal.
std::size_t sourceLinkHash(const Acts::SourceLink &sl)
Calculates the source link hash which is evaluated to be the identifier of the underlying sourcelink.
RecoTrackStateContainer::TrackStateProxy RecoTrackStateContainerProxy
Acts::TrackContainer< Acts::VectorTrackContainer, Acts::VectorMultiTrajectory > RecoTrackContainer
void addToExpectedLayerPattern(std::array< unsigned int, 4 > &pattern, const ActsDetectorElement &detElement)
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
DetectorElementKey makeDetectorElementKey(xAOD::UncalibMeasType meas_type, unsigned int identifier_hash)
const xAOD::UncalibratedMeasurement * firstMeasurement(const xAOD::MuonSegment &segment, const bool skipOutlier=true)
Retrieves the first measurement associated with the segment.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
TrackFitter
Enums to identify who created this track and which properties does it have.
@ KalmanFitter
tracks produced by the Kalman Fitter
static const Acts::GeometryIdentifier & getValue(const value_type &element)
static const Acts::Surface * getSurface(const value_type &element)
Surface of the detector element, or nullptr if none was stored.
std::size_t size() const noexcept
static void setFitterType(trackproxy_t &trackProxy, xAOD::TrackFitter fitterType)
set fitter type of a track
static void add(track_container_t &trackContainer)
static void set(track_proxy_t &track, std::array< unsigned int, 4 > values)