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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
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,14 +8,19 @@

#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)
Expand All @@ -35,6 +40,7 @@ ActsExamples::EventGenerator::EventGenerator(const Config& cfg,

m_outputParticles.initialize(m_cfg.outputParticles);
m_outputVertices.initialize(m_cfg.outputVertices);
m_outputTrackParameters.maybeInitialize(m_cfg.outputTrackParameters);
}

std::string ActsExamples::EventGenerator::name() const {
Expand Down Expand Up @@ -115,8 +121,40 @@ ActsExamples::ProcessCode ActsExamples::EventGenerator::read(
<< " n_primary_vertices=" << nPrimaryVertices
<< " n_particles=" << particles.size());

if (m_outputTrackParameters.isInitialized()) {
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));
}

// move generated event to the store
m_outputParticles(ctx, std::move(particles));
m_outputVertices(ctx, std::move(vertices));

return ProcessCode::SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#include "Acts/Utilities/Logger.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
#include "ActsExamples/EventData/SimVertex.hpp"
#include "ActsExamples/EventData/Track.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
#include "ActsExamples/Framework/IReader.hpp"
#include "ActsExamples/Framework/ProcessCode.hpp"
#include "ActsExamples/Framework/RandomNumbers.hpp"

#include <cstddef>
#include <functional>
#include <memory>
#include <string>
#include <utility>
Expand Down Expand Up @@ -93,8 +93,11 @@ 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;
/// Optional. Name of the output track parameters collection.
std::string outputTrackParameters;

/// List of generators that should be used to generate the event.
std::vector<Generator> generators;
/// The random number service.
Expand Down Expand Up @@ -123,6 +126,8 @@ class EventGenerator final : public ActsExamples::IReader {
WriteDataHandle<SimParticleContainer> m_outputParticles{this,
"OutputParticles"};
WriteDataHandle<SimVertexContainer> m_outputVertices{this, "OutputVertices"};
WriteDataHandle<TrackParametersContainer> m_outputTrackParameters{
this, "OutputTrackParameters"};
};

} // namespace ActsExamples

This file was deleted.

Loading
Loading