Skip to content

Commit

Permalink
Merge branch 'main' into explicit-core
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger authored Oct 18, 2024
2 parents c8cca24 + 2a82fda commit 2b3afce
Show file tree
Hide file tree
Showing 59 changed files with 464 additions and 428 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 7 additions & 3 deletions CI/physmon/workflows/physmon_trackfinding_1muon.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
EtaConfig,
PhiConfig,
ParticleConfig,
ParticleSelectorConfig,
addFatras,
addDigitization,
)

from acts.examples.reconstruction import (
addSeeding,
TruthSeedRanges,
ParticleSmearingSigmas,
SeedFinderConfigArg,
SeedFinderOptionsArg,
Expand Down Expand Up @@ -72,6 +72,11 @@ def run_ckf_tracking(label, seeding):
setup.field,
enableInteractions=True,
rnd=rnd,
postSelectParticles=ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
measurements=(9, None),
removeNeutral=True,
),
)

addDigitization(
Expand All @@ -86,7 +91,6 @@ def run_ckf_tracking(label, seeding):
s,
setup.trackingGeometry,
setup.field,
TruthSeedRanges(pt=(500 * u.MeV, None), nHits=(9, None)),
ParticleSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared
# zero eveything so the CKF has a chance to find the measurements
d0=0,
Expand Down Expand Up @@ -134,7 +138,7 @@ def run_ckf_tracking(label, seeding):
setup.trackingGeometry,
setup.field,
TrackSelectorConfig(
pt=(500 * u.MeV, None),
pt=(0.9 * u.GeV, None),
loc0=(-4.0 * u.mm, 4.0 * u.mm),
nMeasurementsMin=6,
maxHoles=2,
Expand Down
10 changes: 7 additions & 3 deletions CI/physmon/workflows/physmon_trackfinding_4muon_50vertices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
EtaConfig,
PhiConfig,
ParticleConfig,
ParticleSelectorConfig,
addFatras,
addDigitization,
)
from acts.examples.reconstruction import (
addSeeding,
TruthSeedRanges,
SeedFinderConfigArg,
SeedFinderOptionsArg,
SeedingAlgorithm,
Expand Down Expand Up @@ -69,6 +69,11 @@
setup.trackingGeometry,
setup.field,
rnd=rnd,
postSelectParticles=ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
measurements=(9, None),
removeNeutral=True,
),
)

addDigitization(
Expand All @@ -83,7 +88,6 @@
s,
setup.trackingGeometry,
setup.field,
TruthSeedRanges(pt=(500.0 * u.MeV, None), nHits=(9, None)),
SeedFinderConfigArg(
r=(33 * u.mm, 200 * u.mm),
deltaR=(1 * u.mm, 60 * u.mm),
Expand Down Expand Up @@ -116,7 +120,7 @@
setup.trackingGeometry,
setup.field,
TrackSelectorConfig(
pt=(500 * u.MeV, None),
pt=(0.9 * u.GeV, None),
loc0=(-4.0 * u.mm, 4.0 * u.mm),
nMeasurementsMin=6,
maxHoles=2,
Expand Down
7 changes: 5 additions & 2 deletions CI/physmon/workflows/physmon_trackfinding_ttbar_pu200.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
)
from acts.examples.reconstruction import (
addSeeding,
TruthSeedRanges,
SeedFinderConfigArg,
SeedFinderOptionsArg,
SeedingAlgorithm,
Expand Down Expand Up @@ -68,6 +67,11 @@
rho=(0.0, 24 * u.mm),
absZ=(0.0, 1.0 * u.m),
),
postSelectParticles=ParticleSelectorConfig(
pt=(0.5 * u.GeV, None),
measurements=(9, None),
removeNeutral=True,
),
)

addDigitization(
Expand All @@ -82,7 +86,6 @@
s,
setup.trackingGeometry,
setup.field,
TruthSeedRanges(pt=(500.0 * u.MeV, None), nHits=(9, None)),
SeedFinderConfigArg(
r=(33 * u.mm, 200 * u.mm),
deltaR=(1 * u.mm, 60 * u.mm),
Expand Down
1 change: 1 addition & 0 deletions Core/include/Acts/Seeding/HoughTransformUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/Result.hpp"

#include <algorithm>
#include <array>
#include <map>
#include <optional>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class TrackFindingAlgorithm final : public IAlgorithm {
mutable std::atomic<std::size_t> m_nFoundTracks{0};
mutable std::atomic<std::size_t> m_nSelectedTracks{0};
mutable std::atomic<std::size_t> m_nStoppedBranches{0};
mutable std::atomic<std::size_t> m_nSkippedSecondPass{0};

mutable tbb::combinable<Acts::VectorMultiTrajectory::Statistics>
m_memoryStatistics{[]() {
Expand Down
10 changes: 10 additions & 0 deletions Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,15 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const {
Acts::BoundTrackParameters secondInitialParameters =
trackCandidate.createParametersFromState(firstMeasurement);

if (!secondInitialParameters.referenceSurface().insideBounds(
secondInitialParameters.localPosition())) {
m_nSkippedSecondPass++;
ACTS_DEBUG(
"Smoothing of first pass fit produced out-of-bounds parameters "
"relative to the surface. Skipping second pass.");
continue;
}

auto secondRootBranch = tracksTemp.makeTrack();
secondRootBranch.copyFrom(trackCandidate, false);
auto secondResult =
Expand Down Expand Up @@ -681,6 +690,7 @@ ProcessCode TrackFindingAlgorithm::finalize() {
ACTS_INFO("- found tracks: " << m_nFoundTracks);
ACTS_INFO("- selected tracks: " << m_nSelectedTracks);
ACTS_INFO("- stopped branches: " << m_nStoppedBranches);
ACTS_INFO("- skipped second pass: " << m_nSkippedSecondPass);

auto memoryStatistics =
m_memoryStatistics.combine([](const auto& a, const auto& b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@ ActsExamples::ParticleSelector::ParticleSelector(const Config& config,
if (m_cfg.outputParticles.empty()) {
throw std::invalid_argument("Missing output particles collection");
}
if (!m_cfg.outputParticlesFinal.empty() &&
m_cfg.inputParticlesFinal.empty()) {
throw std::invalid_argument(
"Output final particles collection requires input final particles");
}

m_inputParticles.initialize(m_cfg.inputParticles);
m_inputParticlesFinal.maybeInitialize(m_cfg.inputParticlesFinal);
m_outputParticles.initialize(m_cfg.outputParticles);
m_outputParticlesFinal.maybeInitialize(m_cfg.outputParticlesFinal);

ACTS_DEBUG("selection particle rho [" << m_cfg.rhoMin << "," << m_cfg.rhoMax
<< ")");
Expand All @@ -52,29 +59,15 @@ ActsExamples::ParticleSelector::ParticleSelector(const Config& config,
ACTS_DEBUG("remove charged particles " << m_cfg.removeCharged);
ACTS_DEBUG("remove neutral particles " << m_cfg.removeNeutral);
ACTS_DEBUG("remove secondary particles " << m_cfg.removeSecondaries);

// We only initialize this if we actually select on this
if (m_cfg.measurementsMin > 0 ||
m_cfg.measurementsMax < std::numeric_limits<std::size_t>::max()) {
m_inputMap.initialize(m_cfg.inputMeasurementParticlesMap);
ACTS_DEBUG("selection particle number of measurements ["
<< m_cfg.measurementsMin << "," << m_cfg.measurementsMax << ")");
}
}

ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(
const AlgorithmContext& ctx) const {
using ParticlesMeasurmentMap =
boost::container::flat_multimap<ActsFatras::Barcode, Index>;

// prepare input/ output types
const auto& inputParticles = m_inputParticles(ctx);

// Make global particles measurement map if necessary
std::optional<ParticlesMeasurmentMap> particlesMeasMap;
if (m_inputMap.isInitialized()) {
particlesMeasMap = invertIndexMultimap(m_inputMap(ctx));
}
const SimParticleContainer& inputParticles = m_inputParticles(ctx);
const SimParticleContainer& inputParticlesFinal =
(m_inputParticlesFinal.isInitialized()) ? m_inputParticlesFinal(ctx)
: inputParticles;

std::size_t nInvalidCharge = 0;
std::size_t nInvalidMeasurementCount = 0;
Expand All @@ -96,17 +89,14 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(

nInvalidCharge += static_cast<std::size_t>(!validCharge);

// default valid measurement count to true and only change if we have loaded
// the measurement particles map
bool validMeasurementCount = true;
if (particlesMeasMap) {
auto [b, e] = particlesMeasMap->equal_range(p.particleId());
if (auto finalParticleIt = inputParticlesFinal.find(p.particleId());
finalParticleIt != inputParticlesFinal.end()) {
validMeasurementCount =
within(static_cast<std::size_t>(std::distance(b, e)),
m_cfg.measurementsMin, m_cfg.measurementsMax);

ACTS_VERBOSE("Found " << std::distance(b, e) << " measurements for "
<< p.particleId());
within(finalParticleIt->numberOfHits(), m_cfg.measurementsMin,
m_cfg.measurementsMax);
} else {
ACTS_WARNING("No final particle found for " << p.particleId());
}

nInvalidMeasurementCount +=
Expand Down Expand Up @@ -136,14 +126,30 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(
SimParticleContainer outputParticles;
outputParticles.reserve(inputParticles.size());

SimParticleContainer outputParticlesFinal;
if (m_outputParticlesFinal.isInitialized()) {
outputParticlesFinal.reserve(inputParticles.size());
}

// copy selected particles
for (const auto& inputParticle : inputParticles) {
if (isValidParticle(inputParticle)) {
// the input parameters should already be
outputParticles.insert(outputParticles.end(), inputParticle);
if (!isValidParticle(inputParticle)) {
continue;
}

outputParticles.insert(outputParticles.end(), inputParticle);

if (m_outputParticlesFinal.isInitialized()) {
if (auto particleFinalIt =
inputParticlesFinal.find(inputParticle.particleId());
particleFinalIt != inputParticlesFinal.end()) {
outputParticlesFinal.insert(outputParticlesFinal.end(),
*particleFinalIt);
}
}
}
outputParticles.shrink_to_fit();
outputParticlesFinal.shrink_to_fit();

ACTS_DEBUG("event " << ctx.eventNumber << " selected "
<< outputParticles.size() << " from "
Expand All @@ -153,5 +159,9 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(
<< nInvalidMeasurementCount);

m_outputParticles(ctx, std::move(outputParticles));
if (m_outputParticlesFinal.isInitialized()) {
m_outputParticlesFinal(ctx, std::move(outputParticlesFinal));
}

return ProcessCode::SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ class ParticleSelector final : public IAlgorithm {
struct Config {
/// The input particles collection.
std::string inputParticles;
/// Input measurement particles map (Optional)
std::string inputMeasurementParticlesMap;
/// Optional. The input final state particles collection.
/// If provided, this will be used to access the number of measurements.
std::string inputParticlesFinal;
/// The output particles collection.
std::string outputParticles;
/// Optional. The output final state particles collection.
std::string outputParticlesFinal;

// Minimum/maximum distance from the origin in the transverse plane.
double rhoMin = 0;
double rhoMax = std::numeric_limits<double>::infinity();
Expand Down Expand Up @@ -79,11 +83,13 @@ class ParticleSelector final : public IAlgorithm {
Config m_cfg;

ReadDataHandle<SimParticleContainer> m_inputParticles{this, "InputParticles"};
ReadDataHandle<IndexMultimap<ActsFatras::Barcode>> m_inputMap{
this, "InputMeasurementParticlesMap"};
ReadDataHandle<SimParticleContainer> m_inputParticlesFinal{
this, "InputParticlesFinal"};

WriteDataHandle<SimParticleContainer> m_outputParticles{this,
"OutputParticles"};
WriteDataHandle<SimParticleContainer> m_outputParticlesFinal{
this, "OutputParticlesFinal"};
};

} // namespace ActsExamples
2 changes: 0 additions & 2 deletions Examples/Io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ add_subdirectory(Csv)
add_subdirectory_if(EDM4hep ACTS_BUILD_EXAMPLES_EDM4HEP)
add_subdirectory_if(HepMC3 ACTS_BUILD_EXAMPLES_HEPMC3)
add_subdirectory(Json)
add_subdirectory(NuclearInteractions)
add_subdirectory(Obj)
add_subdirectory(Performance)
add_subdirectory(Root)
add_subdirectory_if(Svg ACTS_BUILD_PLUGIN_ACTSVG)
20 changes: 0 additions & 20 deletions Examples/Io/NuclearInteractions/CMakeLists.txt

This file was deleted.

7 changes: 7 additions & 0 deletions Examples/Io/Root/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ add_library(
src/RootVertexReader.cpp
src/RootVertexWriter.cpp
src/RootAthenaDumpReader.cpp
src/RootNuclearInteractionParametersWriter.cpp
src/detail/NuclearInteractionParametrisation.cpp
src/CKFPerformanceWriter.cpp
src/SeedingPerformanceWriter.cpp
src/TrackFinderPerformanceWriter.cpp
src/TrackFitterPerformanceWriter.cpp
src/VertexPerformanceWriter.cpp
)
target_include_directories(
ActsExamplesIoRoot
Expand Down
Loading

0 comments on commit 2b3afce

Please sign in to comment.