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

feat: Pythia8 label secondary vertices based on proximity in Examples #3048

Merged
merged 18 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 16 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2017-2019 CERN for the benefit of the Acts project
// Copyright (C) 2017-2024 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
Expand Down Expand Up @@ -115,10 +115,15 @@ Pythia8Generator::operator()(RandomEngine& rng) {
// only secondaries have a defined vertex position
if (m_cfg.labelSecondaries && genParticle.hasVertex()) {
// either add to existing secondary vertex if exists or create new one
// TODO can we do this w/o the manual search and position check?
auto it = std::find_if(
vertices.begin(), vertices.end(),
[=](const SimVertex& other) { return pos4 == other.position4; });

// check if an existing vertex is close enough
auto it =
std::find_if(vertices.begin(), vertices.end(),
[&pos4, this](const SimVertex& other) {
return (pos4.head<3>() - other.position()).norm() <
m_cfg.spatialVertexThreshold;
});

if (it != vertices.end()) {
particleId.setVertexSecondary(std::distance(vertices.begin(), it));
it->outgoing.insert(particleId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2017-2019 CERN for the benefit of the Acts project
// Copyright (C) 2017-2024 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
Expand Down Expand Up @@ -45,7 +45,9 @@ class Pythia8Generator : public EventGenerator::ParticlesGenerator {
/// Turn on/off the labeling of secondary vertices
/// TODO this is essentially broken as the current code will label any kind
/// of decay as secondary
bool labelSecondaries = false;
bool labelSecondaries = true;
/// The spatial threshold to consider a particle originating from a vertex
double spatialVertexThreshold = 1.0 * Acts::UnitConstants::um;
};

Pythia8Generator(const Config& cfg, Acts::Logging::Level lvl);
Expand Down
Loading