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& detrayDetector =
m_hostDetector->as<traccc::itk_detector>();
138 const detray::tracking_surface detray_surface{detrayDetector, 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& detrayDetector =
m_hostDetector->as<traccc::itk_detector>();
194 const detray::tracking_surface detray_surface{detrayDetector, 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());
254 if(stripMeasMap->size() == 0 || pixelMeasMap->size() == 0){
255 ATH_MSG_FATAL(
"Maps relating traccc measurements to xAOD cluster containers are empty!!");
256 return StatusCode::FAILURE;
263 auto copy =
m_copy->copy(ctx);
265 traccc_track_container::buffer traccc_tracks_buffer;
266 traccc_tracks_buffer.tracks =
267 copy->to(tracks->tracks,
m_hostMR->mr(),
268 nullptr, vecmem::copy::type::device_to_host);
269 traccc_tracks_buffer.states =
270 copy->to(tracks->states,
m_hostMR->mr(),
271 nullptr, vecmem::copy::type::device_to_host);
273 traccc_track_container::const_device traccc_tracks(
274 traccc_tracks_buffer);
276 ATH_MSG_DEBUG(
"Read " << traccc_tracks.tracks.size() <<
" tracks from device.");
280 Acts::VectorTrackContainer trackBackend;
281 Acts::VectorMultiTrajectory trackStateBackend;
283 std::move(trackStateBackend));
286 unsigned nExcludedFitOutcome = 0;
287 unsigned nExcludedNoState = 0;
288 unsigned nExcludedBadNdf = 0;
289 unsigned nExcludedWeirdState = 0;
290 unsigned nExcludedWeirdGlobal = 0;
292 for (std::size_t i = 0; i < traccc_tracks.tracks.size(); ++i) {
294 const traccc::edm::track track = traccc_tracks.tracks.at(i);
296 const auto fitOutcome = track.fit_outcome();
297 if (fitOutcome == traccc::track_fit_outcome::FAILURE_NON_POSITIVE_NDF ||
298 fitOutcome == traccc::track_fit_outcome::FAILURE_NOT_ALL_SMOOTHED ||
299 fitOutcome == traccc::track_fit_outcome::UNKNOWN) {
301 <<
static_cast<int>(fitOutcome));
302 ++nExcludedFitOutcome;
306 if (track.constituent_links().empty()) {
312 static_cast<float>(std::numeric_limits<unsigned int>::max()) ||
314 static_cast<float>(std::numeric_limits<unsigned int>::min())) {
321 auto actsTrack = trackContainer.makeTrack();
322 actsTrack.chi2() = track.chi2();
323 actsTrack.nDoF() = track.ndf();
325 Acts::TrackStatePropMask
const state_mask =
326 Acts::TrackStatePropMask::Smoothed;
328 bool firstState =
true;
330 for (
const auto [linkType, stateIdx] : track.constituent_links()) {
332 assert(linkType == traccc::edm::track_constituent_link::track_state);
334 const auto& state = traccc_tracks.states.at(stateIdx);
335 const auto& meas_index = state.measurement_index();
337 auto trackState = actsTrack.appendTrackState(state_mask);
338 trackState.typeFlags().setIsMeasurement();
340 const std::optional<Acts::BoundTrackParameters> smoothed =
344 ATH_MSG_DEBUG(
"Track " << i <<
": degenerate smoothed state, "
351 &
makeSourceLink(meas_index, *pixelMeasMap, *stripMeasMap, *pixel_clusters, *strip_clusters);
361 const std::optional<Acts::BoundTrackParameters> global =
366 <<
": degenerate global parameters, "
371 actsTrack.parameters() = global->parameters();
372 actsTrack.covariance() = *global->covariance();
373 actsTrack.setReferenceSurface(
374 global->referenceSurface().getSharedPtr());
379 trackState.setReferenceSurface(
380 smoothed->referenceSurface().getSharedPtr());
381 trackState.smoothed() = smoothed->parameters();
382 trackState.smoothedCovariance() = *smoothed->covariance();
383 }
catch (
const std::exception& e) {
384 ATH_MSG_ERROR(
"Track " << i <<
": failed to set track state ("
391 ++nExcludedWeirdState;
392 trackContainer.removeTrack(actsTrack.index());
394 ++nExcludedWeirdGlobal;
395 trackContainer.removeTrack(actsTrack.index());
398 const auto& pars = actsTrack.parameters();
399 const double qop = pars[Acts::eBoundQOverP];
400 const double p = (qop != 0) ? 1.0 / std::abs(qop) : 0.0;
401 const double pT = p * std::sin(pars[Acts::eBoundTheta]);
403 << track.constituent_links().size()
404 <<
" chi2=" << track.chi2()
405 <<
" ndf=" << track.ndf()
406 <<
" |p|=" << p <<
" GeV pT=" << pT <<
" GeV");
413 << nExcludedFitOutcome <<
" (fit outcome), "
414 << nExcludedNoState <<
" (no state), "
415 << nExcludedBadNdf <<
" (bad ndf), "
416 << nExcludedWeirdState <<
" (weird state), "
417 << nExcludedWeirdGlobal <<
" (weird global params)");
427 Acts::ConstVectorTrackContainer constTrackBackend(
428 std::move(trackContainer.container()));
429 Acts::ConstVectorMultiTrajectory constTrackStateBackend(
430 std::move(trackContainer.trackStateContainer()));
431 auto constTrackContainer = std::make_unique<ActsTrk::TrackContainer>(
432 std::move(constTrackBackend), std::move(constTrackStateBackend));
438 return StatusCode::SUCCESS;