Skip to content

Commit

Permalink
fix: createAndPut constTracks correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
wdconinc committed Nov 12, 2023
1 parent 536e3f9 commit 7dda67e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions JugTrack/src/components/CKFTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@
#include "ActsExamples/EventData/IndexSourceLink.hpp"
#include "ActsExamples/EventData/Track.hpp"

#include "fmt/format.h"
#include <fmt/core.h>
#include <fmt/ostream.h>

#include "edm4eic/TrackerHitCollection.h"

#include <functional>
#include <stdexcept>
#include <system_error>
#include <type_traits>
#include <vector>
#include <random>
#include <stdexcept>
Expand Down Expand Up @@ -115,7 +118,6 @@ namespace Jug::Reco {
const auto* const measurements = m_inputMeasurements.get();

//// Prepare the output data with MultiTrajectory
auto* acts_tracks = m_outputTracks.createAndPut();
auto* acts_trajectories = m_outputTrajectories.createAndPut();
acts_trajectories->reserve(init_trk_params->size());

Expand Down Expand Up @@ -196,7 +198,9 @@ namespace Jug::Reco {
std::make_shared<Acts::ConstVectorTrackContainer>(
std::move(*trackContainer));

ActsExamples::ConstTrackContainer constTracks(constTrackContainer, constTrackStateContainer);
auto* constTracks = m_outputTracks.put(
std::make_unique<ActsExamples::ConstTrackContainer>(constTrackContainer, constTrackStateContainer)
);

// Seed number column accessor
const Acts::ConstTrackAccessor<unsigned int> constSeedNumber("seed");
Expand All @@ -207,16 +211,16 @@ namespace Jug::Reco {
std::vector<Acts::MultiTrajectoryTraits::IndexType> tips;

std::optional<unsigned int> lastSeed;
for (const auto& track : constTracks) {
for (const auto& track : *constTracks) {
if (!lastSeed) {
lastSeed = constSeedNumber(track);
}

if (constSeedNumber(track) != lastSeed.value()) {
// make copies and clear vectors
acts_trajectories.push_back(new ActsExamples::Trajectories(
constTracks.trackStateContainer(),
tips, parameters));
acts_trajectories->emplace_back(
constTracks->trackStateContainer(),
tips, parameters);

tips.clear();
parameters.clear();
Expand All @@ -237,9 +241,9 @@ namespace Jug::Reco {
}

// last entry: move vectors
acts_trajectories.push_back(new ActsExamples::Trajectories(
constTracks.trackStateContainer(),
std::move(tips), std::move(parameters)));
acts_trajectories->emplace_back(
constTracks->trackStateContainer(),
std::move(tips), std::move(parameters));

return StatusCode::SUCCESS;
}
Expand Down

0 comments on commit 7dda67e

Please sign in to comment.