116 {
117 ACTS_DEBUG("TrackFindingGNNAlg::execute() - begin");
118
119 std::optional<Athena::Chrono>
timer;
121
122 const Acts::GeometryContext gctx =
m_ctxProvider.getGeometryContext(ctx);
123 const Acts::MagneticFieldContext mctx =
m_ctxProvider.getMagneticFieldContext(ctx);
124 const Acts::CalibrationContext cctx =
m_ctxProvider.getCalibrationContext(ctx);
125
127
128
133 auto stripSPOVHandle =
136
137 std::vector<const xAOD::SpacePointContainer*> spacePointCollections{
138 pixelSPHandle.cptr(), stripSPHandle.cptr(), stripSPOVHandle.cptr()};
139
142
143 ActsTrk::SeedContainer gnnSeeds;
145
146 ACTS_DEBUG(
"GNN produced " << gnnSeeds.
size() <<
" seed candidates");
147
150
151 Acts::VectorTrackContainer trackBackend;
152 Acts::VectorMultiTrajectory trackStateBackend;
153 constexpr std::size_t nTracksExpected = 3000;
154 trackBackend.reserve(nTracksExpected);
155 trackStateBackend.reserve(nTracksExpected * 30);
158
159
160 ActsTrk::SeedContainer seedContainer;
162 return Acts::fastHypot(
sp->x(),
sp->y(),
sp->z());
163 };
164
165
166 auto spacePointSelector = [&](ActsTrk::SpacePointRange cand)
167 -> std::optional<
168 boost::container::small_vector<const xAOD::SpacePoint*, 3>> {
169
170 boost::container::small_vector<const xAOD::SpacePoint*, 3> picked;
171 if (cand.empty()) {
172 return std::nullopt;
173 }
175 picked.push_back(last);
176 for (std::size_t i = 1;
i < cand.size() && picked.size() < 3; ++i) {
179 picked.push_back(
sp);
181 }
182 }
183 if (picked.size() < 3)
184 return std::nullopt;
185 return picked;
186 };
187
188 auto retrieveSurface = [&](
const ActsTrk::Seed&
seed,
bool useTopSp) ->
const Acts::Surface& {
192 if (!surface) {
193 throw std::runtime_error("retrieveSurface: no Acts surface for GeometryIdentifier " + std::to_string(geoId.value()));
194 }
195 return *surface;
196 };
197
198 for (const ActsTrk::Seed gnnSeed : gnnSeeds) {
199 ActsTrk::SpacePointRange cand = gnnSeed.sp();
200 auto pickedOpt = spacePointSelector(cand);
201 if (!pickedOpt.has_value()) continue;
202
203 auto picked = *pickedOpt;
206 return R_of(a) < R_of(b);
207 });
208 constexpr float quality = 0.f;
209 constexpr float vertexZ = 0.f;
211 ActsTrk::SpacePointRange(picked.data(), picked.size()), quality, vertexZ);
212
214 seed, true, gctx, mctx, cctx, retrieveSurface);
215 if (!initialParamsOpt.has_value()) continue;
216
217 boost::container::small_vector<const xAOD::SpacePoint*, 16> sortedSP;
218 sortedSP.reserve(cand.size());
220 sortedSP.push_back(
sp);
221 std::sort(sortedSP.begin(), sortedSP.end(),
223 return R_of(a) < R_of(b);
224 });
225
226 std::vector<const xAOD::UncalibratedMeasurement*> measList;
227 measList.reserve(sortedSP.size() * 2);
230 measList.push_back(m);
231 }
232 }
233
234 auto fitted =
m_fitterTool->fit(measList, *initialParamsOpt, gctx, mctx, cctx);
235 if (fitted) {
236 for (auto track : *fitted) {
237 auto newTrack = tracks.makeTrack();
238 newTrack.copyFrom(track);
239 }
240 }
241 }
242
243 ACTS_DEBUG("After track fit: " << tracks.size() << " / " << gnnSeeds.size()
244 << " successfull");
245
248
249 Acts::VectorTrackContainer selTrackBackend;
250 selTrackBackend.reserve(trackBackend.size());
253
255 for (auto track : tracks) {
257 auto newTrack = selectedTracks.makeTrack();
258
259
260 newTrack.copyFrom(track);
261 }
262 }
263
264 ACTS_DEBUG("GNN seeds: " << gnnSeeds.size() << ", fitted: " << tracks.size()
265 << ", selected: " << selectedTracks.size());
266
267
268 Acts::ConstVectorTrackContainer constTrackBackend(std::move(selTrackBackend));
269 Acts::ConstVectorMultiTrajectory constTrackStateBackend(std::move(trackStateBackend));
270 std::unique_ptr<ActsTrk::TrackContainer> constTracksContainer
271 = std::make_unique<ActsTrk::TrackContainer>(std::move(constTrackBackend), std::move(constTrackStateBackend) );
272
275 ATH_CHECK(trackContainerHandle.
record(std::move(constTracksContainer)));
276
277 return StatusCode::SUCCESS;
278}
#define ATH_CHECK
Evaluate an expression and check for errors.
Acts::TrackSelector::EtaBinnedConfig m_trackSelectorConfig
ToolHandle< ITrackParamsEstimationTool > m_paramEstimationTool
SG::ReadHandleKey< xAOD::SpacePointContainer > m_xaodStripSpacePointOverlapContainerKey
SG::ReadHandleKey< xAOD::SpacePointContainer > m_xaodPixelSpacePointContainerKey
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
SG::WriteHandleKey< TrackContainer > m_trackContainerKey
Gaudi::Property< double > m_minDeltaR
ContextUtility m_ctxProvider
Utility to fetch the geometry, magnetic field and calibration context in the event.
ServiceHandle< IChronoStatSvc > m_chronoSvc
SG::ReadHandleKey< xAOD::SpacePointContainer > m_xaodStripSpacePointContainerKey
ToolHandle< ActsTrk::IGnnPipelineTool > m_gnnPipelineTool
ToolHandle< IFitterTool > m_fitterTool
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Acts::TrackContainer< Acts::VectorTrackContainer, Acts::VectorMultiTrajectory > RecoTrackContainer
Acts::GeometryIdentifier getSurfaceGeometryIdOfMeasurement(const DetectorElementToActsGeometryIdMap &detector_element_to_geoid, const xAOD::UncalibratedMeasurement &measurement)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
timer(name, disabled=False)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
Seed push_back(SpacePointRange spacePoints, float quality, float vertexZ)
std::size_t size() const noexcept
static void addFitterTypeProperty(track_container_t &tracksContainer)
add fitter column to the track container