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: Replace ParticleSmearing with TrackParameterSmearing in Examples #3784

Merged
merged 28 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f8457f7
refactor: Replace particle smearing by track parameter smearing
andiwand Oct 25, 2024
d558ed2
downstream changes
andiwand Oct 28, 2024
ec15774
bind new output param to python
andiwand Oct 28, 2024
f2a5b7f
more downstream changes
andiwand Oct 28, 2024
4b39171
fix t0
andiwand Oct 29, 2024
47c80f0
revert
andiwand Oct 31, 2024
4584527
Merge branch 'main' into ex-refactor-track-param-smearing
andiwand Nov 1, 2024
b610e1b
pin param smearing for physmon fitter chains
andiwand Nov 1, 2024
75132ff
todo
andiwand Nov 2, 2024
2de8646
implement particle track param extractor
andiwand Nov 2, 2024
786bc6d
pr feedback
andiwand Nov 3, 2024
b093372
Merge branch 'main' into ex-refactor-track-param-smearing
andiwand Nov 6, 2024
99c990a
fix
andiwand Nov 6, 2024
eca524c
Merge branch 'ex-refactor-track-param-smearing' of github.com:andiwan…
andiwand Nov 6, 2024
5d2b18e
Merge branch 'main' of github.com:acts-project/acts into ex-refactor-…
andiwand Nov 26, 2024
3cb0493
Merge branch 'main' of github.com:acts-project/acts into ex-refactor-…
andiwand Nov 27, 2024
4fa295d
fix
andiwand Nov 27, 2024
c8e7908
Merge branch 'main' into ex-refactor-track-param-smearing
andiwand Nov 27, 2024
2792c2c
revert initial sigmas
andiwand Nov 27, 2024
1b980bc
Revert "revert initial sigmas"
andiwand Nov 27, 2024
bd5d24c
revert some sigma changes
andiwand Nov 27, 2024
e88d7a1
revert more initial sigmas
andiwand Nov 27, 2024
a45a733
use extractor
andiwand Nov 27, 2024
ce805e8
fixes
andiwand Nov 27, 2024
350500d
update hashes
andiwand Nov 28, 2024
b391f89
Merge branch 'main' of github.com:acts-project/acts into ex-refactor-…
andiwand Nov 28, 2024
18266a9
fix silly
andiwand Nov 28, 2024
4f5daa0
Merge branch 'main' into ex-refactor-track-param-smearing
kodiakhq[bot] Nov 29, 2024
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
18 changes: 9 additions & 9 deletions CI/physmon/workflows/physmon_trackfinding_1muon.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from acts.examples.reconstruction import (
addSeeding,
ParticleSmearingSigmas,
TrackSmearingSigmas,
SeedFinderConfigArg,
SeedFinderOptionsArg,
SeedingAlgorithm,
Expand Down Expand Up @@ -91,15 +91,15 @@ def run_ckf_tracking(label, seeding):
s,
setup.trackingGeometry,
setup.field,
ParticleSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared
TrackSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared
# zero eveything so the CKF has a chance to find the measurements
d0=0,
d0PtA=0,
d0PtB=0,
z0=0,
z0PtA=0,
z0PtB=0,
t0=0,
loc0=0,
loc0PtA=0,
loc0PtB=0,
loc1=0,
loc1PtA=0,
loc1PtB=0,
time=0,
phi=0,
theta=0,
ptRel=0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@

#include "ActsExamples/Generators/EventGenerator.hpp"

#include "Acts/Surfaces/PerigeeSurface.hpp"
#include "ActsExamples/EventData/SimVertex.hpp"
#include "ActsExamples/EventData/Track.hpp"
#include "ActsExamples/Framework/AlgorithmContext.hpp"
#include "ActsFatras/EventData/Barcode.hpp"
#include "ActsFatras/EventData/Particle.hpp"

#include <limits>
#include <memory>
#include <optional>
#include <ostream>
#include <stdexcept>
#include <unordered_map>

ActsExamples::EventGenerator::EventGenerator(const Config& cfg,
Acts::Logging::Level lvl)
namespace ActsExamples {

EventGenerator::EventGenerator(const Config& cfg, Acts::Logging::Level lvl)
: m_cfg(cfg), m_logger(Acts::getDefaultLogger("EventGenerator", lvl)) {
if (m_cfg.outputParticles.empty()) {
throw std::invalid_argument("Missing output particles collection");
Expand All @@ -37,17 +43,15 @@ ActsExamples::EventGenerator::EventGenerator(const Config& cfg,
m_outputVertices.initialize(m_cfg.outputVertices);
}

std::string ActsExamples::EventGenerator::name() const {
std::string EventGenerator::name() const {
return "EventGenerator";
}

std::pair<std::size_t, std::size_t>
ActsExamples::EventGenerator::availableEvents() const {
std::pair<std::size_t, std::size_t> EventGenerator::availableEvents() const {
return {0u, std::numeric_limits<std::size_t>::max()};
}

ActsExamples::ProcessCode ActsExamples::EventGenerator::read(
const AlgorithmContext& ctx) {
ProcessCode EventGenerator::read(const AlgorithmContext& ctx) {
SimParticleContainer particles;
SimVertexContainer vertices;

Expand Down Expand Up @@ -120,5 +124,8 @@ ActsExamples::ProcessCode ActsExamples::EventGenerator::read(
// move generated event to the store
m_outputParticles(ctx, std::move(particles));
m_outputVertices(ctx, std::move(vertices));

return ProcessCode::SUCCESS;
}

} // namespace ActsExamples
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "ActsExamples/Framework/RandomNumbers.hpp"

#include <cstddef>
#include <functional>
#include <memory>
#include <string>
#include <utility>
Expand Down Expand Up @@ -93,8 +92,9 @@ class EventGenerator final : public ActsExamples::IReader {
struct Config {
/// Name of the output particles collection.
std::string outputParticles;
/// Name of the vertex collection.
/// Name of the output vertex collection.
std::string outputVertices;

/// List of generators that should be used to generate the event.
std::vector<Generator> generators;
/// The random number service.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.

#include "ActsExamples/TruthTracking/ParticleTrackParamExtractor.hpp"

#include "Acts/Surfaces/PerigeeSurface.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
#include "ActsExamples/Framework/AlgorithmContext.hpp"

#include <stdexcept>
#include <utility>

namespace ActsExamples {

ParticleTrackParamExtractor::ParticleTrackParamExtractor(
const Config& config, Acts::Logging::Level level)
: IAlgorithm("ParticleTrackParamExtractor", level), m_cfg(config) {
if (m_cfg.inputParticles.empty()) {
throw std::invalid_argument("Missing input particles collection");
}
if (m_cfg.outputTrackParameters.empty()) {
throw std::invalid_argument("Missing output track parameters collection");
}

m_inputParticles.initialize(m_cfg.inputParticles);
m_outputTrackParameters.initialize(m_cfg.outputTrackParameters);
}

ActsExamples::ProcessCode ParticleTrackParamExtractor::execute(
const AlgorithmContext& ctx) const {
const SimParticleContainer& particles = m_inputParticles(ctx);

std::unordered_map<SimBarcode, std::shared_ptr<Acts::PerigeeSurface>>
perigeeSurfaces;

for (auto&& [vtxId, vtxParticles] : groupBySecondaryVertex(particles)) {
// a group contains at least one particle by construction. assume that all
// particles within the group originate from the same position and use it
// to as the reference position for the perigee frame.
auto perigee = Acts::Surface::makeShared<Acts::PerigeeSurface>(
vtxParticles.begin()->position());
perigeeSurfaces[vtxId] = perigee;
}

// create track parameters from the particles
TrackParametersContainer trackParameters;

for (const auto& particle : particles) {
const auto vtxId = particle.particleId().vertexId();
const auto particleHypothesis = particle.hypothesis();
const auto phi = Acts::VectorHelpers::phi(particle.direction());
const auto theta = Acts::VectorHelpers::theta(particle.direction());
const auto qOverP = particle.qOverP();
const auto time = particle.time();

trackParameters.emplace_back(
perigeeSurfaces.at(vtxId),
Acts::BoundVector{0, 0, phi, theta, qOverP, time}, std::nullopt,
particleHypothesis);
}

m_outputTrackParameters(ctx, std::move(trackParameters));

return ProcessCode::SUCCESS;
}

} // namespace ActsExamples
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.

#pragma once

#include "Acts/Utilities/Logger.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
#include "ActsExamples/EventData/Track.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
#include "ActsExamples/Framework/IAlgorithm.hpp"
#include "ActsExamples/Framework/ProcessCode.hpp"

#include <string>

namespace ActsExamples {
struct AlgorithmContext;

/// Extract track parameters from particles.
class ParticleTrackParamExtractor final : public IAlgorithm {
public:
struct Config {
/// The input particles collection.
std::string inputParticles;
/// The output track parameters collection.
std::string outputTrackParameters;
};

ParticleTrackParamExtractor(const Config& config, Acts::Logging::Level level);

ProcessCode execute(const AlgorithmContext& ctx) const final;
andiwand marked this conversation as resolved.
Show resolved Hide resolved

/// Get readonly access to the config parameters
const Config& config() const { return m_cfg; }

private:
Config m_cfg;

ReadDataHandle<SimParticleContainer> m_inputParticles{this, "InputParticles"};
WriteDataHandle<TrackParametersContainer> m_outputTrackParameters{
this, "OutputTrackParameters"};
andiwand marked this conversation as resolved.
Show resolved Hide resolved
};

} // namespace ActsExamples
Loading
Loading