ATLAS Offline Software
FPGATrackSimPrototrackFitterAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
9 }
10 
12  ATH_CHECK(m_trackContainerKey.initialize());
13  ATH_CHECK(m_tracksBackendHandlesHelper.initialize(ActsTrk::prefixFromTrackContainerName(m_trackContainerKey.key())));
14  ATH_CHECK(m_actsFitter.retrieve());
15  ATH_CHECK(m_detEleCollKeys.initialize());
16  ATH_CHECK(m_trackingGeometryTool.retrieve());
17  ATH_CHECK(m_ATLASConverterTool.retrieve());
18  ATH_CHECK(m_extrapolationTool.retrieve());
19  ATH_CHECK(m_ProtoTrackCollectionFromFPGAKey.initialize());
20 
21  return StatusCode::SUCCESS;
22 }
23 
25 {
26 
27  SG::WriteHandle<ActsTrk::TrackContainer> trackContainerHandle (m_trackContainerKey, ctx);
28  SG::ReadHandle<ActsTrk::ProtoTrackCollection> myProtoTracks(m_ProtoTrackCollectionFromFPGAKey,ctx);
29 
30  if (!myProtoTracks.isValid()){
31  ATH_MSG_WARNING("no Prototrack collections");
32  return StatusCode::SUCCESS;
33  }
34  ATH_MSG_DEBUG("I received " <<myProtoTracks->size()<<" proto-tracks");
35 
36 
46 
47  std::vector<const InDetDD::SiDetectorElementCollection *> detEleColl;
48  detEleColl.reserve(m_detEleCollKeys.size());
49  for (const auto &detEleCollKey : m_detEleCollKeys)
50  {
51  ATH_MSG_DEBUG("Reading input condition data with key " << detEleCollKey.key());
52  SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> detEleCollHandle(detEleCollKey, ctx);
53  ATH_CHECK(detEleCollHandle.isValid());
54  detEleColl.push_back(detEleCollHandle.retrieve());
55  if (detEleColl.back() == nullptr)
56  {
57  ATH_MSG_FATAL(detEleCollKey.fullKey() << " is not available.");
58  return StatusCode::FAILURE;
59  }
60  ATH_MSG_DEBUG("Retrieved " << detEleColl.back()->size() << " input condition elements from key " << detEleCollKey.key());
61  }
62 
63  TrackingSurfaceHelper trackingSurfaceHelper;
64  for (auto & coll : detEleColl)
65  {
66  for (const auto *det_el : *coll){
67  const Acts::Surface &surface =
68  m_ATLASConverterTool->trkSurfaceToActsSurface(det_el->surface());
70  if (det_el->isPixel()) type = xAOD::UncalibMeasType::PixelClusterType;
71  else if (det_el->isSCT()) type = xAOD::UncalibMeasType::StripClusterType;
72  trackingSurfaceHelper.actsSurfaces(type).push_back(&surface);
73  }
74  }
75  for (const auto & coll : detEleColl)
76  {
78  if (coll->front()->isPixel()) measType = xAOD::UncalibMeasType::PixelClusterType;
80  trackingSurfaceHelper.setSiDetectorElements(measType, coll);
81  }
82  Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
83  Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
84  // CalibrationContext converter not implemented yet.
85  Acts::CalibrationContext calContext = Acts::CalibrationContext();
86 
89  ActsTrk::MutableTrackContainer trackContainer;
90 
91  // now we fit each of the proto tracks
92  for (auto & proto : *myProtoTracks){
93  auto res = m_actsFitter->fit(ctx, proto.measurements, *proto.parameters,
94  m_trackingGeometryTool->getGeometryContext(ctx).context(),
95  m_extrapolationTool->getMagneticFieldContext(ctx),
96  Acts::CalibrationContext(),
97  trackingSurfaceHelper);
98 
99  if(!res) continue;
100  if (res->size() == 0 ) continue;
101  if(proto.measurements.empty()) continue;
102  ATH_MSG_DEBUG(".......Done track with size "<< proto.measurements.size());
103  const auto trackProxy = res->getTrack(0);
104  if (not trackProxy.hasReferenceSurface()) {
105  ATH_MSG_INFO("There is not reference surface for this track");
106  continue;
107  }
108  auto destProxy = trackContainer.getTrack(trackContainer.addTrack());
109  destProxy.copyFrom(trackProxy, true); // make sure we copy track states!
110  }
111  std::unique_ptr<ActsTrk::TrackContainer> constTracksContainer = m_tracksBackendHandlesHelper.moveToConst(std::move(trackContainer),
112  m_trackingGeometryTool->getGeometryContext(ctx).context(), ctx);
113  ATH_CHECK(trackContainerHandle.record(std::move(constTracksContainer)));
114 
115  return StatusCode::SUCCESS;
116 }
117 
118 
TrackingSurfaceHelper
Simple helper class which allows to access the tracking surface associated to a certain (Si-)measurem...
Definition: TrackingSurfaceHelper.h:17
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
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:11
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
xAOD::UncalibMeasType::StripClusterType
@ StripClusterType
TrackingSurfaceHelper::setSiDetectorElements
void setSiDetectorElements(xAOD::UncalibMeasType type, const InDetDD::SiDetectorElementCollection *det_element_collection)
Definition: TrackingSurfaceHelper.h:29
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
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:18
TrackingSurfaceHelper::actsSurfaces
std::vector< const Acts::Surface * > & actsSurfaces(xAOD::UncalibMeasType type)
Definition: TrackingSurfaceHelper.h:25
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: FPGATrackSimPrototrackFitterAlg.cxx:24
SG::ReadCondHandle::retrieve
const_pointer_type retrieve()
Definition: ReadCondHandle.h:162
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:14
xAOD::Other
@ Other
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
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
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
FPGATrackSim::FPGATrackSimPrototrackFitterAlg::FPGATrackSimPrototrackFitterAlg
FPGATrackSimPrototrackFitterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FPGATrackSimPrototrackFitterAlg.cxx:8
xAOD::UncalibMeasType
UncalibMeasType
Define the type of the uncalibrated measurement.
Definition: MeasurementDefs.h:24
ActsTrk::MutableTrackContainer
Definition: TrackContainer.h:122
xAOD::UncalibMeasType::PixelClusterType
@ PixelClusterType