ATLAS Offline Software
FPGATrackSimPrototrackFitterAlg.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 
8 
9 constexpr bool enableBenchmark =
10 #ifdef BENCHMARK_FPGATRACKSIM
11  true;
12 #else
13  false;
14 #endif
15 
19  ATH_CHECK(m_actsFitter.retrieve());
21  ATH_CHECK(m_extrapolationTool.retrieve());
23  ATH_CHECK(m_chrono.retrieve());
24  return StatusCode::SUCCESS;
25 }
26 
28 {
29 
30  SG::WriteHandle<ActsTrk::TrackContainer> trackContainerHandle (m_trackContainerKey, ctx);
31  SG::ReadHandle<ActsTrk::ProtoTrackCollection> myProtoTracks(m_ProtoTrackCollectionFromFPGAKey,ctx);
32 
33  if (!myProtoTracks.isValid()){
34  ATH_MSG_WARNING("no Prototrack collections");
35  return StatusCode::SUCCESS;
36  }
37  ATH_MSG_DEBUG("I received " <<myProtoTracks->size()<<" proto-tracks");
38 
39 
49  const Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
50  const Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
51  const Acts::CalibrationContext calContext{ActsTrk::getCalibrationContext(ctx)};
52 
55  Acts::VectorTrackContainer trackBackend;
56  Acts::VectorMultiTrajectory trackStateBackend;
57  ActsTrk::MutableTrackContainer trackContainer( std::move(trackBackend),
58  std::move(trackStateBackend) );
59 
60  if constexpr (enableBenchmark) m_chrono->chronoStart("FPGATrackSimPrototrackFitterAlg: ACTS KF");
61  // now we fit each of the proto tracks
62  for (auto & proto : *myProtoTracks){
63  auto res = m_actsFitter->fit(proto.measurements, *proto.parameters,
64  tgContext, mfContext, calContext);
65 
66  if(!res) continue;
67  if (res->size() == 0 ) continue;
68  if(proto.measurements.empty()) continue;
69  ATH_MSG_DEBUG(".......Done track with size "<< proto.measurements.size());
70  const auto trackProxy = res->getTrack(0);
71  if (not trackProxy.hasReferenceSurface()) {
72  ATH_MSG_INFO("There is not reference surface for this track");
73  continue;
74  }
75  auto destProxy = trackContainer.getTrack(trackContainer.addTrack());
76  destProxy.copyFrom(trackProxy, true); // make sure we copy track states!
77  }
78  if constexpr (enableBenchmark) m_chrono->chronoStop("FPGATrackSimPrototrackFitterAlg: ACTS KF");
79 
80  // convert to const
81  Acts::ConstVectorTrackContainer ctrackBackend( std::move(trackContainer.container()) );
82  Acts::ConstVectorMultiTrajectory ctrackStateBackend( std::move(trackContainer.trackStateContainer()) );
83  std::unique_ptr<ActsTrk::TrackContainer> constTracksContainer = std::make_unique<ActsTrk::TrackContainer>( std::move(ctrackBackend),
84  std::move(ctrackStateBackend) );
85 
86  ATH_CHECK(trackContainerHandle.record(std::move(constTracksContainer)));
87 
88  return StatusCode::SUCCESS;
89 }
90 
91 
ActsTrk::getCalibrationContext
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
Definition: CalibrationContext.h:15
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::initialize
virtual StatusCode initialize() override final
uncomment and implement methods as required
Definition: FPGATrackSimPrototrackFitterAlg.cxx:16
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::m_actsFitter
ToolHandle< ActsTrk::IFitterTool > m_actsFitter
Definition: FPGATrackSimPrototrackFitterAlg.h:33
ActsTrk::MutableTrackContainer
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
Definition: TrackContainer.h:26
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::m_tracksBackendHandlesHelper
ActsTrk::MutableTrackContainerHandlesHelper m_tracksBackendHandlesHelper
Definition: FPGATrackSimPrototrackFitterAlg.h:41
ActsTrk::prefixFromTrackContainerName
std::string prefixFromTrackContainerName(const std::string &tracks)
Parse TrackContainer name to get the prefix for backends The name has to contain XYZTracks,...
Definition: TrackContainerHandlesHelper.cxx:20
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
ActsTrk::MutableTrackContainerHandlesHelper::initialize
StatusCode initialize(const std::string &prefix)
Sets up the handles.
Definition: TrackContainerHandlesHelper.cxx:47
CalibrationContext.h
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::m_extrapolationTool
ToolHandle< IActsExtrapolationTool > m_extrapolationTool
Definition: FPGATrackSimPrototrackFitterAlg.h:37
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: FPGATrackSimPrototrackFitterAlg.cxx:27
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:11
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::m_trackingGeometryTool
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Definition: FPGATrackSimPrototrackFitterAlg.h:35
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
enableBenchmark
constexpr bool enableBenchmark
Definition: FPGATrackSimPrototrackFitterAlg.cxx:9
python.TrackLeptonConfig.trackContainer
string trackContainer
Definition: TrackLeptonConfig.py:23
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
Definition: FPGATrackSimPrototrackFitterAlg.h:45
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::m_trackContainerKey
SG::WriteHandleKey< ActsTrk::TrackContainer > m_trackContainerKey
Definition: FPGATrackSimPrototrackFitterAlg.h:39
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
FPGATrackSimPrototrackFitterAlg.h
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::m_ProtoTrackCollectionFromFPGAKey
SG::ReadHandleKey< ActsTrk::ProtoTrackCollection > m_ProtoTrackCollectionFromFPGAKey
Definition: FPGATrackSimPrototrackFitterAlg.h:43