Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: disambiguate seeds and prototracks in examples #1906

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CI/physmon/phys_perf_mon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function full_chain() {

if [ $suffix != truth_smeared ]; then
run \
$outdir/performance_seeding_hists_${suffix}.root \
$refdir/performance_seeding_hists_${suffix}.root \
$outdir/performance_seeding_${suffix}.root \
$refdir/performance_seeding_${suffix}.root \
--title "Seeding ${suffix}" \
-c $config \
-o $outdir/seeding_${suffix}.html \
Expand Down
4 changes: 2 additions & 2 deletions CI/physmon/physmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ def run_ckf_tracking(truthSmearedSeeded, truthEstimatedSeeded, label):
del s

for stem in ["performance_ckf", "performance_vertexing"] + (
["performance_seeding_hists", "performance_ambi"]
["performance_seeding", "performance_ambi"]
if label in ["seeded", "orthogonal"]
else ["performance_seeding_hists"]
else ["performance_seeding"]
if label == "truth_estimated"
else []
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class HoughTransformSeeder final : public IAlgorithm {
std::string outputProtoTracks;
/// Input source links collection.
std::string inputSourceLinks;
/// Tracking geometry required to access global-to-local transforms.
std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry;
/// For which part of the detector geometry should space points be created.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class SeedingAlgorithm final : public IAlgorithm {
std::vector<std::string> inputSpacePoints;
/// Output track seed collection.
std::string outputSeeds;
/// Output proto track collection.
std::string outputProtoTracks;

Acts::SeedFilterConfig seedFilterConfig;
Acts::SeedFinderConfig<SimSpacePoint> seedFinderConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class SeedingOrthogonalAlgorithm final : public IAlgorithm {
std::vector<std::string> inputSpacePoints;
/// Output track seed collection.
std::string outputSeeds;
/// Output proto track collection.
std::string outputProtoTracks;

Acts::SeedFilterConfig seedFilterConfig;
Acts::SeedFinderOrthogonalConfig<SimSpacePoint> seedFinderConfig;
Expand Down
22 changes: 0 additions & 22 deletions Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/FpeMonitor.hpp"
#include "ActsExamples/EventData/IndexSourceLink.hpp"
#include "ActsExamples/EventData/ProtoTrack.hpp"
#include "ActsExamples/EventData/SimSeed.hpp"
#include "ActsExamples/Framework/WhiteBoard.hpp"

Expand All @@ -42,9 +41,6 @@ ActsExamples::SeedingAlgorithm::SeedingAlgorithm(
throw std::invalid_argument("Invalid space point input collection");
}
}
if (m_cfg.outputProtoTracks.empty()) {
throw std::invalid_argument("Missing proto tracks output collection");
}
if (m_cfg.outputSeeds.empty()) {
throw std::invalid_argument("Missing seeds output collection");
}
Expand Down Expand Up @@ -253,27 +249,9 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithm::execute(
group.bottom(), group.middle(), group.top(), rMiddleSPRange);
}

// extract proto tracks, i.e. groups of measurement indices, from tracks seeds
size_t nSeeds = seeds.size();
static thread_local ProtoTrackContainer protoTracks;
protoTracks.clear();

protoTracks.reserve(nSeeds);
for (const auto& seed : seeds) {
ProtoTrack& protoTrack = protoTracks.emplace_back();
protoTrack.reserve(seed.sp().size());
for (auto spacePointPtr : seed.sp()) {
for (const auto& slink : spacePointPtr->sourceLinks()) {
const IndexSourceLink& islink = slink.get<IndexSourceLink>();
protoTrack.emplace_back(islink.index());
}
}
}

ACTS_DEBUG("Created " << seeds.size() << " track seeds from "
<< spacePointPtrs.size() << " space points");

ctx.eventStore.add(m_cfg.outputSeeds, SimSeedContainer{seeds});
ctx.eventStore.add(m_cfg.outputProtoTracks, ProtoTrackContainer{protoTracks});
return ActsExamples::ProcessCode::SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ ActsExamples::SeedingOrthogonalAlgorithm::SeedingOrthogonalAlgorithm(
throw std::invalid_argument("Invalid space point input collection");
}
}
if (m_cfg.outputProtoTracks.empty()) {
throw std::invalid_argument("Missing proto tracks output collection");
}
if (m_cfg.outputSeeds.empty()) {
throw std::invalid_argument("Missing seeds output collection");
}
Expand Down Expand Up @@ -80,30 +77,10 @@ ActsExamples::ProcessCode ActsExamples::SeedingOrthogonalAlgorithm::execute(
SimSeedContainer seeds = finder.createSeeds(m_cfg.seedFinderOptions,
spacePoints, create_coordinates);

// extract proto tracks, i.e. groups of measurement indices, from tracks seeds
size_t nSeeds = seeds.size();
ProtoTrackContainer protoTracks;
protoTracks.reserve(nSeeds);
for (const auto &seed : seeds) {
ProtoTrack protoTrack;
protoTrack.reserve(seed.sp().size());
for (auto spacePointPtr : seed.sp()) {
if (spacePointPtr->sourceLinks().empty()) {
ACTS_WARNING("Missing sourcelink in space point");
continue;
}
const IndexSourceLink &slink =
spacePointPtr->sourceLinks()[0].get<IndexSourceLink>();
protoTrack.push_back(slink.index());
}
protoTracks.push_back(std::move(protoTrack));
}

ACTS_DEBUG("Created " << seeds.size() << " track seeds from "
<< spacePoints.size() << " space points");

ctx.eventStore.add(m_cfg.outputSeeds, std::move(seeds));
ctx.eventStore.add(m_cfg.outputProtoTracks, std::move(protoTracks));

return ActsExamples::ProcessCode::SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ ActsExamples::TruthSeedingAlgorithm::TruthSeedingAlgorithm(
if (m_cfg.outputParticles.empty()) {
throw std::invalid_argument("Missing output particles collection");
}
if (m_cfg.outputFullProtoTracks.empty()) {
throw std::invalid_argument("Missing output full proto tracks collection");
}
if (m_cfg.outputSeeds.empty()) {
throw std::invalid_argument("Missing seeds output collections");
}
Expand Down Expand Up @@ -84,12 +81,10 @@ ActsExamples::ProcessCode ActsExamples::TruthSeedingAlgorithm::execute(
}

SimParticleContainer seededParticles;
ProtoTrackContainer fullTracks;
SimSeedContainer seeds;
ProtoTrackContainer tracks;

seededParticles.reserve(particles.size());
fullTracks.reserve(particles.size());
seeds.reserve(particles.size());
tracks.reserve(particles.size());

Expand All @@ -111,22 +106,22 @@ ActsExamples::ProcessCode ActsExamples::TruthSeedingAlgorithm::execute(
const auto& hits =
makeRange(particleHitsMap.equal_range(particle.particleId()));
// fill hit indices to create the proto track
ProtoTrack fullTrack;
fullTrack.reserve(hits.size());
ProtoTrack track;
track.reserve(hits.size());
for (const auto& hit : hits) {
fullTrack.push_back(hit.second);
track.push_back(hit.second);
}

// The list of hits and the initial start parameters
if (fullTrack.size() < 3) {
if (track.size() < 3) {
ACTS_WARNING("Particle " << particle << " has less than 3 hits");
continue;
}
// Space points on the proto track
std::vector<const SimSpacePoint*> spacePointsOnTrack;
spacePointsOnTrack.reserve(fullTrack.size());
spacePointsOnTrack.reserve(track.size());
// Loop over the hit index on the proto track to find the space points
for (const auto& hitIndex : fullTrack) {
for (const auto& hitIndex : track) {
auto it = spMap.find(hitIndex);
if (it != spMap.end()) {
spacePointsOnTrack.push_back(it->second);
Expand Down Expand Up @@ -175,19 +170,7 @@ ActsExamples::ProcessCode ActsExamples::TruthSeedingAlgorithm::execute(
*spacePointsOnTrack[bestSPIndices[2]],
static_cast<float>(spacePointsOnTrack[bestSPIndices[1]]->z())};

ProtoTrack track;
track.reserve(3);
for (const auto& sp : seed.sp()) {
if (sp->sourceLinks().empty()) {
ACTS_ERROR("Missing source link in the space point")
continue;
}
const auto slink = sp->sourceLinks()[0].get<IndexSourceLink>();
track.push_back(slink.index());
}

seededParticles.insert(particle);
fullTracks.emplace_back(std::move(fullTrack));
seeds.emplace_back(std::move(seed));
tracks.emplace_back(std::move(track));
}
Expand All @@ -196,7 +179,6 @@ ActsExamples::ProcessCode ActsExamples::TruthSeedingAlgorithm::execute(
ACTS_VERBOSE("Found " << seeds.size() << " seeds");

ctx.eventStore.add(m_cfg.outputParticles, std::move(seededParticles));
ctx.eventStore.add(m_cfg.outputFullProtoTracks, std::move(fullTracks));
ctx.eventStore.add(m_cfg.outputSeeds, std::move(seeds));
ctx.eventStore.add(m_cfg.outputProtoTracks, std::move(tracks));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class TruthSeedingAlgorithm final : public IAlgorithm {
std::vector<std::string> inputSpacePoints;
/// Output successfully seeded truth particles.
std::string outputParticles;
/// Output full proto track collection.
std::string outputFullProtoTracks;
/// Output seed collection.
std::string outputSeeds;
/// Output proto track collection.
Expand Down
1 change: 1 addition & 0 deletions Examples/Algorithms/Utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_library(
ActsExamplesUtilities SHARED
src/SeedsToPrototracks.cpp
src/TrajectoriesToPrototracks.cpp
src/TracksToTrajectories.cpp)
target_include_directories(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// This file is part of the Acts project.
//
// Copyright (C) 2022 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#pragma once

#include "ActsExamples/Framework/IAlgorithm.hpp"

namespace ActsExamples {

class SeedsToPrototracks final : public IAlgorithm {
public:
struct Config {
std::string inputSeeds = "seeds";
std::string outputProtoTracks = "tracks-from-seeds";
};

/// Construct the algorithm.
///
/// @param cfg is the algorithm configuration
/// @param lvl is the logging level
SeedsToPrototracks(Config cfg, Acts::Logging::Level lvl)
: IAlgorithm("TrajectoriesToPrototracks", lvl), m_cfg(std::move(cfg)) {}

/// Run the algorithm.
///
/// @param ctx is the algorithm context with event information
/// @return a process code indication success or failure
ProcessCode execute(const AlgorithmContext& ctx) const final;

/// Const access to the config
const Config& config() const { return m_cfg; }

private:
Config m_cfg;
};

} // namespace ActsExamples
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TrajectoriesToPrototracks final : public IAlgorithm {
public:
struct Config {
std::string inputTrajectories = "trajectories";
std::string outputPrototracks = "tracks-from-trajectories";
std::string outputProtoTracks = "tracks-from-trajectories";
};

/// Construct the algorithm.
Expand Down
28 changes: 28 additions & 0 deletions Examples/Algorithms/Utilities/src/SeedsToPrototracks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// This file is part of the Acts project.
//
// Copyright (C) 2022 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include "ActsExamples/Utilities/SeedsToPrototracks.hpp"

#include "ActsExamples/EventData/IndexSourceLink.hpp"
#include "ActsExamples/EventData/ProtoTrack.hpp"
#include "ActsExamples/EventData/SimSeed.hpp"
#include "ActsExamples/Framework/WhiteBoard.hpp"
#include "ActsExamples/Utilities/EventDataTransforms.hpp"

namespace ActsExamples {

ProcessCode SeedsToPrototracks::execute(const AlgorithmContext& ctx) const {
const auto seeds = ctx.eventStore.get<SimSeedContainer>(m_cfg.inputSeeds);

auto tracks = seedsToPrototracks(seeds);

ctx.eventStore.add(m_cfg.outputProtoTracks, std::move(tracks));

return ProcessCode::SUCCESS;
}
} // namespace ActsExamples
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ProcessCode TrajectoriesToPrototracks::execute(
}
}

ctx.eventStore.add(m_cfg.outputPrototracks, std::move(tracks));
ctx.eventStore.add(m_cfg.outputProtoTracks, std::move(tracks));

return ProcessCode::SUCCESS;
}
Expand Down
1 change: 1 addition & 0 deletions Examples/Framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_library(
src/Framework/WhiteBoard.cpp
src/Framework/RandomNumbers.cpp
src/Framework/Sequencer.cpp
src/Utilities/EventDataTransforms.cpp
src/Utilities/Paths.cpp
src/Utilities/Options.cpp
src/Utilities/Helpers.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#pragma once

#include "ActsExamples/EventData/ProtoTrack.hpp"
#include "ActsExamples/EventData/SimSeed.hpp"

namespace ActsExamples {

ProtoTrack seedToPrototrack(const SimSeed &seed);

ProtoTrackContainer seedsToPrototracks(const SimSeedContainer &seeds);

} // namespace ActsExamples
34 changes: 34 additions & 0 deletions Examples/Framework/src/Utilities/EventDataTransforms.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of the Acts project.
//
// Copyright (C) 2022 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include "ActsExamples/Utilities/EventDataTransforms.hpp"

ActsExamples::ProtoTrack ActsExamples::seedToPrototrack(
const ActsExamples::SimSeed& seed) {
ProtoTrack track;
track.reserve(seed.sp().size());
for (auto spacePointPtr : seed.sp()) {
for (const auto& slink : spacePointPtr->sourceLinks()) {
const auto& islink = slink.get<IndexSourceLink>();
track.emplace_back(islink.index());
}
}
return track;
}

ActsExamples::ProtoTrackContainer ActsExamples::seedsToPrototracks(
const ActsExamples::SimSeedContainer& seeds) {
ProtoTrackContainer tracks;
tracks.reserve(seeds.size());

for (const auto& seed : seeds) {
tracks.push_back(seedToPrototrack(seed));
}

return tracks;
}
Loading