ATLAS Offline Software
Loading...
Searching...
No Matches
ProtoTrackCreationAndFitAlg.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
10#include <stdlib.h>
11
12
13
27
28StatusCode ActsTrk::ProtoTrackCreationAndFitAlg::execute(const EventContext & ctx) const {
29
30 // Read the pixel and strip cluster list
33 if (!thePixelClusters.isValid()){
34 ATH_MSG_FATAL("no Pixel clusters");
35 return StatusCode::FAILURE;
36 }
37 ATH_MSG_DEBUG("I found " <<thePixelClusters->size()<<" pix clusters");
38
39 if (!theStripClusters.isValid()){
40 ATH_MSG_FATAL("no strip clusters");
41 return StatusCode::FAILURE;
42 }
43 ATH_MSG_DEBUG("I found " <<theStripClusters->size()<<" strip clusters");
44
45 // book the output tracks
46 auto trackContainerHandle = SG::makeHandle(m_trackContainerKey, ctx);
47
48 // call the user-provided track finder
49 auto myProtoTracks = std::make_unique<ActsTrk::ProtoTrackCollection>();
50 ATH_CHECK(m_patternBuilder->findProtoTracks(ctx,
51 *thePixelClusters,
52 *theStripClusters,
53 *myProtoTracks ));
54 ATH_MSG_INFO("I received " << myProtoTracks->size() << " proto-tracks");
55
65 const Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
66 const Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
67 const Acts::CalibrationContext calContext{getCalibrationContext(ctx)};
68
71 Acts::VectorTrackContainer trackBackend;
72 Acts::VectorMultiTrajectory trackStateBackend;
73 ActsTrk::detail::RecoTrackContainer trackContainer( trackBackend, trackStateBackend );
74
75 // now we fit each of the proto tracks
76 for (auto & proto : *myProtoTracks){
77 auto res = m_actsFitter->fit(proto.measurements,*proto.parameters,
78 tgContext, mfContext, calContext);
79
80 if(!res) continue;
81 if (res->size() == 0 ) continue;
82 if(not proto.measurements.size()) continue;
83 ATH_MSG_DEBUG(".......Done track with size "<< proto.measurements.size());
84 const auto trackProxy = res->getTrack(0);
85 if (not trackProxy.hasReferenceSurface()) {
86 ATH_MSG_INFO("There is not reference surface for this track");
87 continue;
88 }
89 auto destProxy = trackContainer.getTrack(trackContainer.addTrack());
90 destProxy.copyFrom(trackProxy);
92 ATH_MSG_VERBOSE("original " << proto.parameters->parameters());
93 proto.parameters =
94 std::make_unique<Acts::BoundTrackParameters>( trackProxy.referenceSurface().getSharedPtr(),
95 trackProxy.parameters(),
96 trackProxy.covariance(),
97 trackProxy.particleHypothesis());
98 ATH_MSG_VERBOSE("corrected" << proto.parameters->parameters());
99 }
100
101 }
102
103 ActsTrk::TrackBackend constTrackBackend( std::move(trackBackend) );
104 ActsTrk::TrackStateBackend constTrackStateBackend( std::move(trackStateBackend) );
105 std::unique_ptr<ActsTrk::TrackContainer> constTracksContainer = std::make_unique<ActsTrk::TrackContainer>( std::move(constTrackBackend),
106 std::move(constTrackStateBackend) );
107 ATH_CHECK(trackContainerHandle.record(std::move(constTracksContainer)));
108
109 if (not m_protoTrackCollectionKey.empty()) {
110 auto handle = SG::makeHandle(m_protoTrackCollectionKey, ctx);
111 ATH_CHECK(handle.record(std::move(myProtoTracks)));
112 }
113
114 return StatusCode::SUCCESS;
115}
116
117
#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
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
SG::ReadHandleKey< xAOD::StripClusterContainer > m_StripClusters
SG::WriteHandleKey< ActsTrk::TrackContainer > m_trackContainerKey
virtual StatusCode execute(const EventContext &ctx) const override final
ToolHandle< ActsTrk::IProtoTrackCreatorTool > m_patternBuilder
ToolHandle< ActsTrk::IFitterTool > m_actsFitter
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
ActsTrk::MutableTrackContainerHandlesHelper m_tracksBackendHandlesHelper
SG::WriteHandleKey< ActsTrk::ProtoTrackCollection > m_protoTrackCollectionKey
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::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
Acts::ConstVectorMultiTrajectory TrackStateBackend
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())