Skip to content

Commit

Permalink
Merge branch 'ex-remove-sourcelink-container' of github.com:andiwand/…
Browse files Browse the repository at this point in the history
…acts into ex-remove-sourcelink-container
  • Loading branch information
andiwand committed Oct 15, 2024
2 parents 976e772 + 183e233 commit 1e1c49c
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 267 deletions.
328 changes: 141 additions & 187 deletions Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions Core/include/Acts/TrackFinding/MeasurementSelector.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ MeasurementSelector::select(

ACTS_VERBOSE("Invoked MeasurementSelector");

// Return error if no measurement
// Return if no measurement
if (candidates.empty()) {
return CombinatorialKalmanFilterError::MeasurementSelectionFailed;
return Result::success(std::pair(candidates.begin(), candidates.end()));
}

// Get geoID of this surface
Expand Down Expand Up @@ -92,20 +92,19 @@ MeasurementSelector::select(
"No measurement candidate. Return an outlier measurement chi2="
<< minChi2);
isOutlier = true;
return Result::success(std::make_pair(candidates.begin() + minIndex,
candidates.begin() + minIndex + 1));
return Result::success(std::pair(candidates.begin() + minIndex,
candidates.begin() + minIndex + 1));
} else {
ACTS_VERBOSE("No measurement candidate. Return empty chi2=" << minChi2);
return Result::success(
std::make_pair(candidates.begin(), candidates.begin()));
return Result::success(std::pair(candidates.begin(), candidates.begin()));
}
}

if (passedCandidates <= 1ul) {
// return single item range, no sorting necessary
ACTS_VERBOSE("Returning only 1 element chi2=" << minChi2);
return Result::success(std::make_pair(candidates.begin() + minIndex,
candidates.begin() + minIndex + 1));
return Result::success(std::pair(candidates.begin() + minIndex,
candidates.begin() + minIndex + 1));
}

std::sort(
Expand All @@ -115,7 +114,7 @@ MeasurementSelector::select(
ACTS_VERBOSE("Number of selected measurements: "
<< passedCandidates << ", max: " << cuts.numMeasurements);

return Result::success(std::make_pair(
return Result::success(std::pair(
candidates.begin(),
candidates.begin() + std::min(cuts.numMeasurements, passedCandidates)));
}
Expand Down
41 changes: 24 additions & 17 deletions Core/src/Detector/detail/BlueprintDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,58 +57,65 @@ std::string labelStr(
void Acts::Experimental::detail::BlueprintDrawer::dotStream(
std::ostream& ss, const Acts::Experimental::Blueprint::Node& node,
const Options& options) {
// Replace the "/" in node names
std::string nodeName = node.name;
std::replace(nodeName.begin(), nodeName.end(), '/', '_');

// Root / leaf or branch
if (node.isRoot()) {
ss << "digraph " << options.graphName << " {" << '\n';
ss << node.name << " " << labelStr(options.root, node.name, node.auxiliary)
ss << nodeName << " " << labelStr(options.root, nodeName, node.auxiliary)
<< '\n';
ss << node.name << " " << shapeStr(options.root) << '\n';
ss << nodeName << " " << shapeStr(options.root) << '\n';

} else if (node.isLeaf()) {
ss << node.name << " " << labelStr(options.leaf, node.name, node.auxiliary)
ss << nodeName << " " << labelStr(options.leaf, nodeName, node.auxiliary)
<< '\n';
ss << node.name << " "
ss << nodeName << " "
<< ((node.internalsBuilder != nullptr) ? shapeStr(options.leaf)
: shapeStr(options.gap))
<< '\n';
} else {
ss << node.name << " "
<< labelStr(options.branch, node.name, node.auxiliary) << '\n';
ss << node.name << " " << shapeStr(options.branch) << '\n';
ss << nodeName << " " << labelStr(options.branch, nodeName, node.auxiliary)
<< '\n';
ss << nodeName << " " << shapeStr(options.branch) << '\n';
}
// Recursive for children
for (const auto& c : node.children) {
ss << node.name << " -> " << c->name << ";" << '\n';
// Replace the "/" in node names
std::string childName = c->name;
std::replace(childName.begin(), childName.end(), '/', '_');
ss << nodeName << " -> " << childName << ";" << '\n';
dotStream(ss, *c, options);
}

// Shape
Options::Node shape = node.isLeaf() ? options.shape : options.virtualShape;
std::stringstream bts;
bts << node.boundsType;
ss << node.name + "_shape " << shapeStr(shape) << '\n';
ss << node.name + "_shape "
ss << nodeName + "_shape " << shapeStr(shape) << '\n';
ss << nodeName + "_shape "
<< labelStr(shape, bts.str(),
{"t = " + toString(node.transform.translation(), 1),
"b = " + toString(node.boundaryValues, 1)})
<< '\n';
ss << node.name << " -> " << node.name + "_shape [ arrowhead = \"none\" ];"
ss << nodeName << " -> " << nodeName + "_shape [ arrowhead = \"none\" ];"
<< '\n';

// Sub node detection
if (node.internalsBuilder != nullptr) {
ss << node.name + "_int " << shapeStr(options.internals) << '\n';
ss << node.name << " -> " << node.name + "_int;" << '\n';
ss << nodeName + "_int " << shapeStr(options.internals) << '\n';
ss << nodeName << " -> " << nodeName + "_int;" << '\n';
}

if (node.geoIdGenerator != nullptr) {
ss << node.name + "_geoID " << shapeStr(options.geoID) << '\n';
ss << node.name << " -> " << node.name + "_geoID;" << '\n';
ss << nodeName + "_geoID " << shapeStr(options.geoID) << '\n';
ss << nodeName << " -> " << nodeName + "_geoID;" << '\n';
}

if (node.rootVolumeFinderBuilder != nullptr) {
ss << node.name + "_roots " << shapeStr(options.roots) << '\n';
ss << node.name << " -> " << node.name + "_roots;" << '\n';
ss << nodeName + "_roots " << shapeStr(options.roots) << '\n';
ss << nodeName << " -> " << nodeName + "_roots;" << '\n';
}

if (node.isRoot()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class AlignmentAlgorithm final : public IAlgorithm {
struct Config {
/// Input measurements collection.
std::string inputMeasurements;
/// Input source links collection.
std::string inputSourceLinks;
/// Input proto tracks collection, i.e. groups of hit indices.
std::string inputProtoTracks;
/// Input initial track parameter estimates for for each proto track.
Expand Down
19 changes: 6 additions & 13 deletions Examples/Algorithms/Alignment/src/AlignmentAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Acts/Surfaces/PerigeeSurface.hpp"
#include "Acts/TrackFitting/GainMatrixSmoother.hpp"
#include "Acts/TrackFitting/GainMatrixUpdater.hpp"
#include "ActsExamples/EventData/IndexSourceLink.hpp"
#include "ActsExamples/EventData/MeasurementCalibration.hpp"
#include "ActsExamples/EventData/ProtoTrack.hpp"
#include "ActsExamples/EventData/Trajectories.hpp"
Expand All @@ -23,9 +24,6 @@ ActsExamples::AlignmentAlgorithm::AlignmentAlgorithm(Config cfg,
if (m_cfg.inputMeasurements.empty()) {
throw std::invalid_argument("Missing input measurement collection");
}
if (m_cfg.inputSourceLinks.empty()) {
throw std::invalid_argument("Missing input source links collection");
}
if (m_cfg.inputProtoTracks.empty()) {
throw std::invalid_argument("Missing input proto tracks collection");
}
Expand All @@ -39,7 +37,6 @@ ActsExamples::AlignmentAlgorithm::AlignmentAlgorithm(Config cfg,
}

m_inputMeasurements.initialize(m_cfg.inputMeasurements);
m_inputSourceLinks.initialize(m_cfg.inputSourceLinks);
m_inputProtoTracks.initialize(m_cfg.inputProtoTracks);
m_inputInitialTrackParameters.initialize(m_cfg.inputInitialTrackParameters);
m_outputAlignmentParameters.initialize(m_cfg.outputAlignmentParameters);
Expand All @@ -49,7 +46,6 @@ ActsExamples::ProcessCode ActsExamples::AlignmentAlgorithm::execute(
const ActsExamples::AlgorithmContext& ctx) const {
// Read input data
const auto& measurements = m_inputMeasurements(ctx);
const auto& sourceLinks = m_inputSourceLinks(ctx);
const auto& protoTracks = m_inputProtoTracks(ctx);
const auto& initialParameters = m_inputInitialTrackParameters(ctx);

Expand Down Expand Up @@ -79,14 +75,11 @@ ActsExamples::ProcessCode ActsExamples::AlignmentAlgorithm::execute(
trackSourceLinks.reserve(protoTrack.size());

// Fill the source links via their indices from the container
for (auto hitIndex : protoTrack) {
auto sourceLink = sourceLinks.nth(hitIndex);
if (sourceLink == sourceLinks.end()) {
ACTS_FATAL("Proto track " << itrack << " contains invalid hit index"
<< hitIndex);
return ProcessCode::ABORT;
}
trackSourceLinks.push_back(*sourceLink);
for (auto measIndex : protoTrack) {
const ConstVariableBoundMeasurementProxy measurement =
measurements.getMeasurement(measIndex);
IndexSourceLink sourceLink(measurement.geometryId(), measIndex);
trackSourceLinks.push_back(sourceLink);
}
sourceLinkTrackContainer.push_back(trackSourceLinks);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ class DigitizationConfig {

/// Input collection of simulated hits.
std::string inputSimHits = "simhits";
/// Output source links collection.
std::string outputSourceLinks = "sourcelinks";
/// Output measurements collection.
std::string outputMeasurements = "measurements";
/// Output cells map (geoID -> collection of cells).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include "ActsExamples/Utilities/TrajectoriesToPrototracks.hpp"

#include "Acts/EventData/MultiTrajectory.hpp"
#include "ActsExamples/EventData/IndexSourceLink.hpp"
#include "ActsExamples/EventData/ProtoTrack.hpp"
#include "ActsExamples/EventData/Trajectories.hpp"

#include <utility>
#include <vector>

namespace ActsExamples {
class IndexSourceLink;
struct AlgorithmContext;

TrajectoriesToPrototracks::TrajectoriesToPrototracks(Config cfg,
Expand Down
2 changes: 0 additions & 2 deletions Examples/Io/Csv/src/CsvMeasurementReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ ActsExamples::ProcessCode ActsExamples::CsvMeasurementReader::read(
MeasurementContainer tmpMeasurements;
GeometryIdMultimap<ConstVariableBoundMeasurementProxy> orderedMeasurements;
IndexMultimap<Index> measurementSimHitsMap;
// need list here for stable addresses
std::list<IndexSourceLink> sourceLinkStorage;

tmpMeasurements.reserve(measurementData.size());
orderedMeasurements.reserve(measurementData.size());
Expand Down
4 changes: 0 additions & 4 deletions Examples/Io/Csv/src/CsvTrackWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
#include <unordered_set>
#include <utility>

namespace ActsExamples {
class IndexSourceLink;
} // namespace ActsExamples

using namespace ActsExamples;

CsvTrackWriter::CsvTrackWriter(const CsvTrackWriter::Config& config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class EDM4hepMeasurementReader final : public IReader {
std::string outputMeasurements;
/// Output measurement to sim hit collection.
std::string outputMeasurementSimHitsMap;
/// Output source links collection.
std::string outputSourceLinks;
/// Output cluster collection (optional).
std::string outputClusters;
};
Expand Down Expand Up @@ -79,9 +77,6 @@ class EDM4hepMeasurementReader final : public IReader {
WriteDataHandle<IndexMultimap<Index>> m_outputMeasurementSimHitsMap{
this, "OutputMeasurementSimHitsMap"};

WriteDataHandle<GeometryIdMultiset<IndexSourceLink>> m_outputSourceLinks{
this, "OutputSourceLinks"};

WriteDataHandle<ClusterContainer> m_outputClusters{this, "OutputClusters"};
};

Expand Down
3 changes: 0 additions & 3 deletions Examples/Io/EDM4hep/src/EDM4hepMeasurementReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ EDM4hepMeasurementReader::EDM4hepMeasurementReader(

m_outputMeasurements.initialize(m_cfg.outputMeasurements);
m_outputMeasurementSimHitsMap.initialize(m_cfg.outputMeasurementSimHitsMap);
m_outputSourceLinks.initialize(m_cfg.outputSourceLinks);
m_outputClusters.maybeInitialize(m_cfg.outputClusters);
}

Expand All @@ -55,7 +54,6 @@ ProcessCode EDM4hepMeasurementReader::read(const AlgorithmContext& ctx) {
ClusterContainer clusters;
// TODO what about those?
IndexMultimap<Index> measurementSimHitsMap;
IndexSourceLinkContainer sourceLinks;

podio::Frame frame = reader().readEntry("events", ctx.eventNumber);

Expand All @@ -76,7 +74,6 @@ ProcessCode EDM4hepMeasurementReader::read(const AlgorithmContext& ctx) {
// Write the data to the EventStore
m_outputMeasurements(ctx, std::move(measurements));
m_outputMeasurementSimHitsMap(ctx, std::move(measurementSimHitsMap));
m_outputSourceLinks(ctx, std::move(sourceLinks));
if (!m_cfg.outputClusters.empty()) {
m_outputClusters(ctx, std::move(clusters));
}
Expand Down
8 changes: 2 additions & 6 deletions Examples/Io/EDM4hep/src/EDM4hepUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ VariableBoundMeasurementProxy EDM4hepUtil::readMeasurement(
// no need for digitization as we only want to identify the sensor
Acts::GeometryIdentifier geometryId = geometryMapper(from.getCellID());

IndexSourceLink sourceLink{
geometryId, static_cast<Index>(podioObjectIDToInteger(from.id()))};

auto pos = from.getPosition();
auto cov = from.getCovMatrix();

Expand All @@ -173,7 +170,7 @@ VariableBoundMeasurementProxy EDM4hepUtil::readMeasurement(
dParameters.values.push_back(pos.z);
dParameters.variances.push_back(cov[5]);

auto to = createMeasurement(container, dParameters, sourceLink);
auto to = createMeasurement(container, geometryId, dParameters);

if (fromClusters != nullptr) {
for (const auto objectId : from.getRawHits()) {
Expand Down Expand Up @@ -202,8 +199,7 @@ void EDM4hepUtil::writeMeasurement(
edm4hep::MutableTrackerHitPlane to, const Cluster* fromCluster,
edm4hep::TrackerHitCollection& toClusters,
const MapGeometryIdTo& geometryMapper) {
Acts::GeometryIdentifier geoId =
from.sourceLink().template get<IndexSourceLink>().geometryId();
Acts::GeometryIdentifier geoId = from.geometryId();

if (geometryMapper) {
// no need for digitization as we only want to identify the sensor
Expand Down
2 changes: 0 additions & 2 deletions Examples/Io/Root/src/RootTrackStatesWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

namespace ActsExamples {

class IndexSourceLink;

using Acts::VectorHelpers::eta;
using Acts::VectorHelpers::perp;
using Acts::VectorHelpers::phi;
Expand Down
5 changes: 0 additions & 5 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ def addSeeding(
logger.info("Using Hough Transform seeding")
houghTransformConfig.inputSpacePoints = [spacePoints]
houghTransformConfig.inputMeasurements = "measurements"
houghTransformConfig.inputSourceLinks = "sourcelinks"
houghTransformConfig.outputProtoTracks = "prototracks"
houghTransformConfig.outputSeeds = "seeds"
houghTransformConfig.trackingGeometry = trackingGeometry
Expand Down Expand Up @@ -635,7 +634,6 @@ def addSpacePointsMaking(
logLevel = acts.examples.defaultLogging(sequence, logLevel)()
spAlg = acts.examples.SpacePointMaker(
level=logLevel,
inputSourceLinks="sourcelinks",
inputMeasurements="measurements",
outputSpacePoints="spacepoints",
trackingGeometry=trackingGeometry,
Expand Down Expand Up @@ -1168,7 +1166,6 @@ def addGbtsSeeding(
geometrySelection=acts.examples.readJsonGeometryList(
str(geoSelectionConfigFile)
),
inputSourceLinks="sourcelinks",
trackingGeometry=trackingGeometry,
fill_module_csv=False,
inputClusters="clusters",
Expand Down Expand Up @@ -1528,7 +1525,6 @@ def addCKFTracks(
]
),
inputMeasurements="measurements",
inputSourceLinks="sourcelinks",
inputInitialTrackParameters="estimatedparameters",
inputSeeds=(
"estimatedseeds"
Expand Down Expand Up @@ -1813,7 +1809,6 @@ def addExaTrkX(
s.addAlgorithm(
acts.examples.SpacePointMaker(
level=customLogLevel(),
inputSourceLinks="sourcelinks",
inputMeasurements="measurements",
outputSpacePoints="spacepoints",
trackingGeometry=trackingGeometry,
Expand Down
1 change: 0 additions & 1 deletion Examples/Python/python/acts/examples/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,6 @@ def addDigitization(
surfaceByIdentifier=trackingGeometry.geoIdSurfaceMap(),
randomNumbers=rnd,
inputSimHits="simhits",
outputSourceLinks="sourcelinks",
outputMeasurements="measurements",
outputMeasurementParticlesMap="measurement_particles_map",
outputMeasurementSimHitsMap="measurement_simhits_map",
Expand Down
1 change: 0 additions & 1 deletion Examples/Python/src/Digitization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void addDigitization(Context& ctx) {

ACTS_PYTHON_STRUCT_BEGIN(c, Config);
ACTS_PYTHON_MEMBER(inputSimHits);
ACTS_PYTHON_MEMBER(outputSourceLinks);
ACTS_PYTHON_MEMBER(outputMeasurements);
ACTS_PYTHON_MEMBER(outputClusters);
ACTS_PYTHON_MEMBER(outputMeasurementParticlesMap);
Expand Down
2 changes: 1 addition & 1 deletion Examples/Python/src/EDM4hepComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PYBIND11_MODULE(ActsPythonBindingsEDM4hep, m) {
ACTS_PYTHON_DECLARE_READER(ActsExamples::EDM4hepMeasurementReader, m,
"EDM4hepMeasurementReader", inputPath,
outputMeasurements, outputMeasurementSimHitsMap,
outputSourceLinks, outputClusters);
outputClusters);

ACTS_PYTHON_DECLARE_WRITER(ActsExamples::EDM4hepMeasurementWriter, m,
"EDM4hepMeasurementWriter", inputMeasurements,
Expand Down
5 changes: 3 additions & 2 deletions Examples/Python/src/GeoModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ void addGeoModel(Context& ctx) {
.def_readwrite(
"topBoundsOverride",
&Acts::GeoModelBlueprintCreater::Options::topBoundsOverride)
.def_readwrite("table",
&Acts::GeoModelBlueprintCreater::Options::table);
.def_readwrite("table", &Acts::GeoModelBlueprintCreater::Options::table)
.def_readwrite("dotGraph",
&Acts::GeoModelBlueprintCreater::Options::dotGraph);
}

gm.def(
Expand Down
Loading

0 comments on commit 1e1c49c

Please sign in to comment.