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