ATLAS Offline Software
Loading...
Searching...
No Matches
ProtoTrackCreationAndFitAlg.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
9#include <stdlib.h>
10
11
12
24
25StatusCode ActsTrk::ProtoTrackCreationAndFitAlg::execute(const EventContext & ctx) const {
26
27 // Read the pixel and strip cluster list
30 if (!thePixelClusters.isValid()){
31 ATH_MSG_FATAL("no Pixel clusters");
32 return StatusCode::FAILURE;
33 }
34 ATH_MSG_DEBUG("I found " <<thePixelClusters->size()<<" pix clusters");
35
36 if (!theStripClusters.isValid()){
37 ATH_MSG_FATAL("no strip clusters");
38 return StatusCode::FAILURE;
39 }
40 ATH_MSG_DEBUG("I found " <<theStripClusters->size()<<" strip clusters");
41
42 // book the output tracks
43 auto trackContainerHandle = SG::makeHandle(m_trackContainerKey, ctx);
44
45 // call the user-provided track finder
46 auto myProtoTracks = std::make_unique<ActsTrk::ProtoTrackCollection>();
47 ATH_CHECK(m_patternBuilder->findProtoTracks(ctx,
48 *thePixelClusters,
49 *theStripClusters,
50 *myProtoTracks ));
51 ATH_MSG_INFO("I received " << myProtoTracks->size() << " proto-tracks");
52
62 const Acts::GeometryContext tgContext = m_ctxProvider.getGeometryContext(ctx);
63 const Acts::MagneticFieldContext mfContext = m_ctxProvider.getMagneticFieldContext(ctx);
64 const Acts::CalibrationContext calContext{m_ctxProvider.getCalibrationContext(ctx)};
65
68 Acts::VectorTrackContainer trackBackend;
69 Acts::VectorMultiTrajectory trackStateBackend;
70 ActsTrk::detail::RecoTrackContainer trackContainer( trackBackend, trackStateBackend );
71
72 bool initializedColumns = false;
73
74 // now we fit each of the proto tracks
75 for (auto & proto : *myProtoTracks){
76 auto res = m_actsFitter->fit(proto.measurements,*proto.parameters,
77 tgContext, mfContext, calContext);
78
79 if(!res) continue;
80 if (res->size() == 0 ) continue;
81 if(not proto.measurements.size()) continue;
82 ATH_MSG_DEBUG(".......Done track with size "<< proto.measurements.size());
83 const auto trackProxy = res->getTrack(0);
84 if (not trackProxy.hasReferenceSurface()) {
85 ATH_MSG_INFO("There is not reference surface for this track");
86 continue;
87 }
88 if (!initializedColumns) {
89 trackContainer.ensureDynamicColumns(*res);
90 initializedColumns = true;
91 }
92 auto destProxy = trackContainer.getTrack(trackContainer.addTrack());
93 destProxy.copyFrom(trackProxy);
95 ATH_MSG_VERBOSE("original " << proto.parameters->parameters());
96 proto.parameters =
97 std::make_unique<Acts::BoundTrackParameters>( trackProxy.referenceSurface().getSharedPtr(),
98 trackProxy.parameters(),
99 trackProxy.covariance(),
100 trackProxy.particleHypothesis());
101 ATH_MSG_VERBOSE("corrected" << proto.parameters->parameters());
102 }
103
104 }
105
106 ActsTrk::TrackBackend constTrackBackend( std::move(trackBackend) );
107 ActsTrk::TrackStateBackend constTrackStateBackend( std::move(trackStateBackend) );
108 std::unique_ptr<ActsTrk::TrackContainer> constTracksContainer = std::make_unique<ActsTrk::TrackContainer>( std::move(constTrackBackend),
109 std::move(constTrackStateBackend) );
110 ATH_CHECK(trackContainerHandle.record(std::move(constTracksContainer)));
111
112 if (not m_protoTrackCollectionKey.empty()) {
113 auto handle = SG::makeHandle(m_protoTrackCollectionKey, ctx);
114 ATH_CHECK(handle.record(std::move(myProtoTracks)));
115 }
116
117 return StatusCode::SUCCESS;
118}
119
120
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
std::pair< std::vector< unsigned int >, bool > res
ToolHandle< IProtoTrackCreatorTool > m_patternBuilder
SG::ReadHandleKey< xAOD::StripClusterContainer > m_StripClusters
virtual StatusCode execute(const EventContext &ctx) const override final
MutableTrackContainerHandlesHelper m_tracksBackendHandlesHelper
SG::WriteHandleKey< ProtoTrackCollection > m_protoTrackCollectionKey
ContextUtility m_ctxProvider
Utility to fetch the geometry, magnetic field and calibration context in the event.
SG::WriteHandleKey< TrackContainer > m_trackContainerKey
SG::ReadHandleKey< xAOD::PixelClusterContainer > m_PixelClusters
virtual StatusCode initialize() override final
uncomment and implement methods as required
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Acts::TrackContainer< Acts::VectorTrackContainer, Acts::VectorMultiTrajectory > RecoTrackContainer
std::string prefixFromTrackContainerName(const std::string &tracks)
Parse TrackContainer name to get the prefix for backends The name has to contain XYZTracks,...
Acts::ConstVectorTrackContainer TrackBackend
Acts::ConstVectorMultiTrajectory TrackStateBackend
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())