127 traccc::bound_track_parameters<traccc::default_algebra>
const& trkParams)
130 if (trkParams.bound_local()[0] == 0 && trkParams.bound_local()[1] == 0 &&
131 trkParams.phi() == 0 && trkParams.theta() == 0 &&
132 trkParams.qop() == 0 && trkParams.time() == 0) {
138 const auto& detrayDetector =
m_hostDetector->as<traccc::itk_detector>();
139 const detray::tracking_surface detray_surface{detrayDetector, trkParams.surface_link()};
140 const auto geo_id = detray_surface.source();
141 const Acts::GeometryIdentifier acts_geom_id{
geo_id};
145 Acts::BoundVector params;
146 params << trkParams.bound_local()[0], trkParams.bound_local()[1],
147 trkParams.phi(), trkParams.theta(), trkParams.qop(), trkParams.time();
150 const double qop = trkParams.qop();
151 const double p = (qop != 0) ? 1.0 / std::abs(qop) : 0.0;
152 const double pT = p * std::sin(trkParams.theta());
153 ATH_MSG_DEBUG(
"Global params: d0=" << trkParams.bound_local()[0]
154 <<
" z0=" << trkParams.bound_local()[1]
155 <<
" phi=" << trkParams.phi()
156 <<
" theta=" << trkParams.theta()
158 <<
" -> |p|=" << p <<
" pT=" << pT
159 <<
" charge=" << (qop > 0 ? +1 : -1)
160 <<
" time=" << trkParams.time());
165 static constexpr unsigned int kAtlasCovSize = 5;
167 Acts::BoundMatrix cov = Acts::BoundMatrix::Identity();
168 const auto& atlasCov = trkParams.covariance();
169 for (
unsigned i = 0; i < kAtlasCovSize; ++i) {
170 for (
unsigned j = 0; j < kAtlasCovSize; ++j) {
171 cov(i, j) = atlasCov[i][j];
175 return Acts::BoundTrackParameters(surface.getSharedPtr(), params, cov,
176 Acts::ParticleHypothesis::pion());
182 traccc::edm::track_state<state_t>
const& state)
const
184 const auto& atlasParam = state.smoothed_params();
186 if (atlasParam.bound_local()[0] == 0 && atlasParam.bound_local()[1] == 0 &&
187 atlasParam.phi() == 0 && atlasParam.theta() == 0 &&
188 atlasParam.qop() == 0 && atlasParam.time() == 0) {
194 const auto& detrayDetector =
m_hostDetector->as<traccc::itk_detector>();
195 const detray::tracking_surface detray_surface{detrayDetector, atlasParam.surface_link()};
196 const auto geo_id = detray_surface.source();
197 const Acts::GeometryIdentifier acts_geom_id{
geo_id};
203 Acts::BoundVector params;
204 params << atlasParam.bound_local()[0], atlasParam.bound_local()[1],
205 atlasParam.phi(), atlasParam.theta(), atlasParam.qop(),
209 const double qop = atlasParam.qop();
210 const double p = (qop != 0) ? 1.0 / std::abs(qop) : 0.0;
211 const double pT = p * std::sin(atlasParam.theta());
212 ATH_MSG_DEBUG(
"Smoothed state: d0=" << atlasParam.bound_local()[0]
213 <<
" z0=" << atlasParam.bound_local()[1]
214 <<
" phi=" << atlasParam.phi()
215 <<
" theta=" << atlasParam.theta()
217 <<
" -> |p|=" << p <<
" pT=" << pT);
222 static constexpr unsigned int kAtlasCovSize = 5;
224 Acts::BoundMatrix cov = Acts::BoundMatrix::Identity();
225 const auto& atlasCov = atlasParam.covariance();
226 for (
unsigned i = 0; i < kAtlasCovSize; ++i) {
227 for (
unsigned j = 0; j < kAtlasCovSize; ++j) {
228 cov(i, j) = atlasCov[i][j];
232 return Acts::BoundTrackParameters(surface.getSharedPtr(), params, cov,
233 Acts::ParticleHypothesis::pion());
255 if(stripMeasMap->size() == 0 || pixelMeasMap->size() == 0){
256 ATH_MSG_FATAL(
"Maps relating traccc measurements to xAOD cluster containers are empty!!");
257 return StatusCode::FAILURE;
264 auto copy =
m_copy->copy(ctx);
266 traccc_track_container::buffer traccc_tracks_buffer;
267 traccc_tracks_buffer.tracks =
268 copy->to(tracks->tracks,
m_hostMR->mr(),
269 nullptr, vecmem::copy::type::device_to_host);
270 traccc_tracks_buffer.states =
271 copy->to(tracks->states,
m_hostMR->mr(),
272 nullptr, vecmem::copy::type::device_to_host);
274 traccc_track_container::const_device traccc_tracks(
275 traccc_tracks_buffer);
277 ATH_MSG_DEBUG(
"Read " << traccc_tracks.tracks.size() <<
" tracks from device.");
281 Acts::VectorTrackContainer trackBackend;
282 Acts::VectorMultiTrajectory trackStateBackend;
284 std::move(trackStateBackend));
287 unsigned nExcludedFitOutcome = 0;
288 unsigned nExcludedNoState = 0;
289 unsigned nExcludedBadNdf = 0;
290 unsigned nExcludedWeirdState = 0;
291 unsigned nExcludedWeirdGlobal = 0;
293 for (std::size_t i = 0; i < traccc_tracks.tracks.size(); ++i) {
295 const traccc::edm::track track = traccc_tracks.tracks.at(i);
297 const auto fitOutcome = track.fit_outcome();
298 if (fitOutcome == traccc::track_fit_outcome::FAILURE_NON_POSITIVE_NDF ||
299 fitOutcome == traccc::track_fit_outcome::FAILURE_NOT_ALL_SMOOTHED ||
300 fitOutcome == traccc::track_fit_outcome::UNKNOWN) {
302 <<
static_cast<int>(fitOutcome));
303 ++nExcludedFitOutcome;
307 if (track.constituent_links().empty()) {
313 static_cast<float>(std::numeric_limits<unsigned int>::max()) ||
315 static_cast<float>(std::numeric_limits<unsigned int>::min())) {
322 auto actsTrack = trackContainer.makeTrack();
323 actsTrack.chi2() = track.chi2();
324 actsTrack.nDoF() = track.ndf();
326 Acts::TrackStatePropMask
const state_mask =
327 Acts::TrackStatePropMask::Smoothed;
329 bool firstState =
true;
331 for (
const auto [linkType, stateIdx] : track.constituent_links()) {
333 assert(linkType == traccc::edm::track_constituent_link::track_state);
335 const auto& state = traccc_tracks.states.at(stateIdx);
336 const auto& meas_index = state.measurement_index();
338 auto trackState = actsTrack.appendTrackState(state_mask);
339 trackState.typeFlags().setIsMeasurement();
341 const std::optional<Acts::BoundTrackParameters> smoothed =
345 ATH_MSG_DEBUG(
"Track " << i <<
": degenerate smoothed state, "
352 &
makeSourceLink(meas_index, *pixelMeasMap, *stripMeasMap, *pixel_clusters, *strip_clusters);
362 const std::optional<Acts::BoundTrackParameters> global =
367 <<
": degenerate global parameters, "
372 actsTrack.parameters() = global->parameters();
373 actsTrack.covariance() = *global->covariance();
374 actsTrack.setReferenceSurface(
375 global->referenceSurface().getSharedPtr());
380 trackState.setReferenceSurface(
381 smoothed->referenceSurface().getSharedPtr());
382 trackState.smoothed() = smoothed->parameters();
383 trackState.smoothedCovariance() = *smoothed->covariance();
384 }
catch (
const std::exception& e) {
385 ATH_MSG_ERROR(
"Track " << i <<
": failed to set track state ("
392 ++nExcludedWeirdState;
393 trackContainer.removeTrack(actsTrack.index());
395 ++nExcludedWeirdGlobal;
396 trackContainer.removeTrack(actsTrack.index());
399 const auto& pars = actsTrack.parameters();
400 const double qop = pars[Acts::eBoundQOverP];
401 const double p = (qop != 0) ? 1.0 / std::abs(qop) : 0.0;
402 const double pT = p * std::sin(pars[Acts::eBoundTheta]);
404 << track.constituent_links().size()
405 <<
" chi2=" << track.chi2()
406 <<
" ndf=" << track.ndf()
407 <<
" |p|=" << p <<
" GeV pT=" << pT <<
" GeV");
414 << nExcludedFitOutcome <<
" (fit outcome), "
415 << nExcludedNoState <<
" (no state), "
416 << nExcludedBadNdf <<
" (bad ndf), "
417 << nExcludedWeirdState <<
" (weird state), "
418 << nExcludedWeirdGlobal <<
" (weird global params)");
428 Acts::ConstVectorTrackContainer constTrackBackend(
429 std::move(trackContainer.container()));
430 Acts::ConstVectorMultiTrajectory constTrackStateBackend(
431 std::move(trackContainer.trackStateContainer()));
432 auto constTrackContainer = std::make_unique<ActsTrk::TrackContainer>(
433 std::move(constTrackBackend), std::move(constTrackStateBackend));
439 return StatusCode::SUCCESS;