126 traccc::bound_track_parameters<traccc::default_algebra>
const& trkParams)
129 if (trkParams.bound_local()[0] == 0 && trkParams.bound_local()[1] == 0 &&
130 trkParams.phi() == 0 && trkParams.theta() == 0 &&
131 trkParams.qop() == 0 && trkParams.time() == 0) {
137 const auto& itkDetector =
m_hostDetector->as<traccc::itk_detector>();
138 const detray::tracking_surface detray_surface{itkDetector, trkParams.surface_link()};
139 const auto geo_id = detray_surface.source();
140 const Acts::GeometryIdentifier acts_geom_id{
geo_id};
144 Acts::BoundVector params;
145 params << trkParams.bound_local()[0], trkParams.bound_local()[1],
146 trkParams.phi(), trkParams.theta(), trkParams.qop(), trkParams.time();
149 const double qop = trkParams.qop();
150 const double p = (qop != 0) ? 1.0 / std::abs(qop) : 0.0;
151 const double pT = p * std::sin(trkParams.theta());
152 ATH_MSG_DEBUG(
"Global params: d0=" << trkParams.bound_local()[0]
153 <<
" z0=" << trkParams.bound_local()[1]
154 <<
" phi=" << trkParams.phi()
155 <<
" theta=" << trkParams.theta()
157 <<
" -> |p|=" << p <<
" pT=" << pT
158 <<
" charge=" << (qop > 0 ? +1 : -1)
159 <<
" time=" << trkParams.time());
164 static constexpr unsigned int kAtlasCovSize = 5;
166 Acts::BoundMatrix cov = Acts::BoundMatrix::Identity();
167 const auto& atlasCov = trkParams.covariance();
168 for (
unsigned i = 0; i < kAtlasCovSize; ++i) {
169 for (
unsigned j = 0; j < kAtlasCovSize; ++j) {
170 cov(i, j) = atlasCov[i][j];
174 return Acts::BoundTrackParameters(surface.getSharedPtr(), params, cov,
175 Acts::ParticleHypothesis::pion());
181 traccc::edm::track_state<state_t>
const& state)
const
183 const auto& atlasParam = state.smoothed_params();
185 if (atlasParam.bound_local()[0] == 0 && atlasParam.bound_local()[1] == 0 &&
186 atlasParam.phi() == 0 && atlasParam.theta() == 0 &&
187 atlasParam.qop() == 0 && atlasParam.time() == 0) {
193 const auto& itkDetector =
m_hostDetector->as<traccc::itk_detector>();
194 const detray::tracking_surface detray_surface{itkDetector, atlasParam.surface_link()};
195 const auto geo_id = detray_surface.source();
196 const Acts::GeometryIdentifier acts_geom_id{
geo_id};
202 Acts::BoundVector params;
203 params << atlasParam.bound_local()[0], atlasParam.bound_local()[1],
204 atlasParam.phi(), atlasParam.theta(), atlasParam.qop(),
208 const double qop = atlasParam.qop();
209 const double p = (qop != 0) ? 1.0 / std::abs(qop) : 0.0;
210 const double pT = p * std::sin(atlasParam.theta());
211 ATH_MSG_DEBUG(
"Smoothed state: d0=" << atlasParam.bound_local()[0]
212 <<
" z0=" << atlasParam.bound_local()[1]
213 <<
" phi=" << atlasParam.phi()
214 <<
" theta=" << atlasParam.theta()
216 <<
" -> |p|=" << p <<
" pT=" << pT);
221 static constexpr unsigned int kAtlasCovSize = 5;
223 Acts::BoundMatrix cov = Acts::BoundMatrix::Identity();
224 const auto& atlasCov = atlasParam.covariance();
225 for (
unsigned i = 0; i < kAtlasCovSize; ++i) {
226 for (
unsigned j = 0; j < kAtlasCovSize; ++j) {
227 cov(i, j) = atlasCov[i][j];
231 return Acts::BoundTrackParameters(surface.getSharedPtr(), params, cov,
232 Acts::ParticleHypothesis::pion());
259 auto copy =
m_copy->copy(ctx);
261 traccc_track_container::buffer traccc_tracks_buffer;
262 traccc_tracks_buffer.tracks =
263 copy->to(tracks->tracks,
m_hostMR->mr(),
264 nullptr, vecmem::copy::type::device_to_host);
265 traccc_tracks_buffer.states =
266 copy->to(tracks->states,
m_hostMR->mr(),
267 nullptr, vecmem::copy::type::device_to_host);
269 traccc_track_container::const_device traccc_tracks(
270 traccc_tracks_buffer);
272 ATH_MSG_DEBUG(
"Read " << traccc_tracks.tracks.size() <<
" tracks from device.");
275 if(stripMeasMap->size() == 0 || pixelMeasMap->size() == 0){
276 ATH_MSG_DEBUG(
"Maps relating traccc measurements to xAOD cluster containers are empty!!");
277 if(traccc_tracks.tracks.size() > 0){
278 ATH_MSG_ERROR(
"Traccc tracks exist but mapping to xAOD clusters is empty, cannot convert tracks to ACTS");
279 return StatusCode::FAILURE;
284 Acts::VectorTrackContainer trackBackend;
285 Acts::VectorMultiTrajectory trackStateBackend;
287 std::move(trackStateBackend));
290 unsigned nExcludedFitOutcome = 0;
291 unsigned nExcludedNoState = 0;
292 unsigned nExcludedBadNdf = 0;
293 unsigned nExcludedWeirdState = 0;
294 unsigned nExcludedWeirdGlobal = 0;
296 for (std::size_t i = 0; i < traccc_tracks.tracks.size(); ++i) {
298 const traccc::edm::track track = traccc_tracks.tracks.at(i);
300 const auto fitOutcome = track.fit_outcome();
301 if (fitOutcome != traccc::track_fit_outcome::SUCCESS) {
303 <<
static_cast<int>(fitOutcome));
304 ++nExcludedFitOutcome;
308 if (track.constituent_links().empty()) {
314 static_cast<float>(std::numeric_limits<unsigned int>::max()) ||
316 static_cast<float>(std::numeric_limits<unsigned int>::min())) {
323 auto actsTrack = trackContainer.makeTrack();
324 actsTrack.chi2() = track.chi2();
325 actsTrack.nDoF() = track.ndf();
327 Acts::TrackStatePropMask
const state_mask =
328 Acts::TrackStatePropMask::Smoothed;
330 bool firstState =
true;
332 for (
const auto [linkType, stateIdx] : track.constituent_links()) {
334 assert(linkType == traccc::edm::track_constituent_link::track_state);
336 const auto& state = traccc_tracks.states.at(stateIdx);
337 const auto& meas_index = state.measurement_index();
339 auto trackState = actsTrack.appendTrackState(state_mask);
340 trackState.typeFlags().setIsMeasurement();
342 const std::optional<Acts::BoundTrackParameters> smoothed =
346 ATH_MSG_DEBUG(
"Track " << i <<
": degenerate smoothed state, "
353 &
makeSourceLink(meas_index, *pixelMeasMap, *stripMeasMap, *pixel_clusters, *strip_clusters);
363 const std::optional<Acts::BoundTrackParameters> global =
368 <<
": degenerate global parameters, "
373 actsTrack.parameters() = global->parameters();
374 actsTrack.covariance() = *global->covariance();
375 actsTrack.setReferenceSurface(
376 global->referenceSurface().getSharedPtr());
381 trackState.setReferenceSurface(
382 smoothed->referenceSurface().getSharedPtr());
383 trackState.smoothed() = smoothed->parameters();
384 trackState.smoothedCovariance() = *smoothed->covariance();
385 }
catch (
const std::exception& e) {
386 ATH_MSG_ERROR(
"Track " << i <<
": failed to set track state ("
393 ++nExcludedWeirdState;
394 trackContainer.removeTrack(actsTrack.index());
396 ++nExcludedWeirdGlobal;
397 trackContainer.removeTrack(actsTrack.index());
400 const auto& pars = actsTrack.parameters();
401 const double qop = pars[Acts::eBoundQOverP];
402 const double p = (qop != 0) ? 1.0 / std::abs(qop) : 0.0;
403 const double pT = p * std::sin(pars[Acts::eBoundTheta]);
405 << track.constituent_links().size()
406 <<
" chi2=" << track.chi2()
407 <<
" ndf=" << track.ndf()
408 <<
" |p|=" << p <<
" GeV pT=" << pT <<
" GeV");
415 << nExcludedFitOutcome <<
" (fit outcome), "
416 << nExcludedNoState <<
" (no state), "
417 << nExcludedBadNdf <<
" (bad ndf), "
418 << nExcludedWeirdState <<
" (weird state), "
419 << nExcludedWeirdGlobal <<
" (weird global params)");
429 Acts::ConstVectorTrackContainer constTrackBackend(
430 std::move(trackContainer.container()));
431 Acts::ConstVectorMultiTrajectory constTrackStateBackend(
432 std::move(trackContainer.trackStateContainer()));
433 auto constTrackContainer = std::make_unique<ActsTrk::TrackContainer>(
434 std::move(constTrackBackend), std::move(constTrackStateBackend));
440 return StatusCode::SUCCESS;