diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp index 8a178e622f0..556f7497544 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp @@ -78,9 +78,7 @@ Acts::AdaptiveMultiVertexFitter::fitImpl( state.vtxInfoMap[currentVtx].constraintVertex.fitQuality()); currentVtx->setFullCovariance( state.vtxInfoMap[currentVtx].constraintVertex.fullCovariance()); - } - - else if (currentVtx->fullCovariance() == SymMatrix4::Zero()) { + } else if (currentVtx->fullCovariance() == SymMatrix4::Zero()) { return VertexingError::NoCovariance; } double weight = diff --git a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp index 0c27e1c5e08..e6cde816c40 100644 --- a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp +++ b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp @@ -59,6 +59,8 @@ class TrackFindingAlgorithm final : public BareAlgorithm { std::string inputInitialTrackParameters; /// Output find trajectories collection. std::string outputTrajectories; + /// Output track parameters collection. + std::string outputTrackParameters; /// Type erased track finder function. std::shared_ptr findTracks; /// CKF measurement selector config diff --git a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp index bb871d80d0d..fb855b70260 100644 --- a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp @@ -51,6 +51,9 @@ ActsExamples::ProcessCode ActsExamples::TrackFindingAlgorithm::execute( TrajectoriesContainer trajectories; trajectories.reserve(initialParameters.size()); + // Prepare the output data with TrackParameters + TrackParametersContainer trackParametersContainer; + // Construct a perigee surface as the target surface auto pSurface = Acts::Surface::makeShared( Acts::Vector3{0., 0., 0.}); @@ -108,6 +111,13 @@ ActsExamples::ProcessCode ActsExamples::TrackFindingAlgorithm::execute( trajectories.emplace_back(trackFindingOutput.fittedStates, trackFindingOutput.lastMeasurementIndices, trackFindingOutput.fittedParameters); + + const auto& traj = trajectories.back(); + for (const auto tip : traj.tips()) { + if (traj.hasTrackParameters(tip)) { + trackParametersContainer.push_back(traj.trackParameters(tip)); + } + } } else { ACTS_WARNING("Track finding failed for seed " << iseed << " with error" << result.error()); @@ -121,5 +131,7 @@ ActsExamples::ProcessCode ActsExamples::TrackFindingAlgorithm::execute( << " track candidates."); ctx.eventStore.add(m_cfg.outputTrajectories, std::move(trajectories)); + ctx.eventStore.add(m_cfg.outputTrackParameters, + std::move(trackParametersContainer)); return ActsExamples::ProcessCode::SUCCESS; } diff --git a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp index 31e4ddacab3..2d02eb17471 100644 --- a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp @@ -129,11 +129,11 @@ ActsExamples::AdaptiveMultiVertexFinderAlgorithm::execute( // find vertices and measure elapsed time auto result = finder.find(inputTrackPointers, finderOpts, state); - if (not result.ok()) { + if (result.ok()) { + vertices = std::move(result.value()); + } else { ACTS_ERROR("Error in vertex finder: " << result.error().message()); - return ProcessCode::ABORT; } - vertices = *result; } auto t2 = std::chrono::high_resolution_clock::now(); diff --git a/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp index fd182c455de..e533a69028f 100644 --- a/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp @@ -106,11 +106,12 @@ ActsExamples::ProcessCode ActsExamples::IterativeVertexFinderAlgorithm::execute( auto result = finder.find(inputTrackPointers, finderOpts, state); auto t2 = std::chrono::high_resolution_clock::now(); - if (not result.ok()) { + std::vector> vertices; + if (result.ok()) { + vertices = std::move(result.value()); + } else { ACTS_ERROR("Error in vertex finder: " << result.error().message()); - return ProcessCode::ABORT; } - auto vertices = *result; // show some debug output ACTS_INFO("Found " << vertices.size() << " vertices in event"); diff --git a/Examples/Algorithms/Vertexing/src/VertexFitterAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/VertexFitterAlgorithm.cpp index cb7ef24bd37..c9400dfd550 100644 --- a/Examples/Algorithms/Vertexing/src/VertexFitterAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/VertexFitterAlgorithm.cpp @@ -88,6 +88,11 @@ ActsExamples::ProcessCode ActsExamples::VertexFitterAlgorithm::execute( inputTrackPtrCollection.clear(); inputTrackPtrCollection.reserve(protoVertex.size()); for (const auto& trackIdx : protoVertex) { + if (trackIdx >= trackParameters.size()) { + ACTS_ERROR("track parameters " << trackIdx << " does not exist"); + continue; + } + inputTrackPtrCollection.push_back(&trackParameters[trackIdx]); } @@ -99,8 +104,7 @@ ActsExamples::ProcessCode ActsExamples::VertexFitterAlgorithm::execute( if (fitRes.ok()) { fittedVertices.push_back(*fitRes); } else { - ACTS_ERROR("Error in vertex fit."); - ACTS_ERROR(fitRes.error().message()); + ACTS_ERROR("Error in vertex fitter: " << fitRes.error().message()); } } else { // Vertex constraint @@ -118,15 +122,19 @@ ActsExamples::ProcessCode ActsExamples::VertexFitterAlgorithm::execute( if (fitRes.ok()) { fittedVertices.push_back(*fitRes); } else { - ACTS_ERROR("Error in vertex fit with constraint."); - ACTS_ERROR(fitRes.error().message()); + ACTS_ERROR( + "Error in constrained vertex fitter: " << fitRes.error().message()); } } - ACTS_DEBUG("Fitted Vertex " - << fittedVertices.back().fullPosition().transpose()); - ACTS_DEBUG( - "Tracks at fitted Vertex: " << fittedVertices.back().tracks().size()); + if (fittedVertices.empty()) { + ACTS_DEBUG("No fitted vertex"); + } else { + ACTS_DEBUG("Fitted Vertex " + << fittedVertices.back().fullPosition().transpose()); + ACTS_DEBUG( + "Tracks at fitted Vertex: " << fittedVertices.back().tracks().size()); + } } ctx.eventStore.add(m_cfg.outputVertices, std::move(fittedVertices)); diff --git a/Examples/Framework/src/Framework/Sequencer.cpp b/Examples/Framework/src/Framework/Sequencer.cpp index 6722deaab26..5db2740f020 100644 --- a/Examples/Framework/src/Framework/Sequencer.cpp +++ b/Examples/Framework/src/Framework/Sequencer.cpp @@ -307,6 +307,7 @@ int ActsExamples::Sequencer::run() { StopWatch sw(localClocksAlgorithms[ialgo++]); ACTS_VERBOSE("Execute algorithm: " << alg->name()); if (alg->execute(++context) != ProcessCode::SUCCESS) { + ACTS_FATAL("Failed to execute algorithm: " << alg->name()); throw std::runtime_error("Failed to process event data"); } } diff --git a/Examples/Python/python/acts/examples/reconstruction.py b/Examples/Python/python/acts/examples/reconstruction.py index 48f049b3052..3afb4538713 100644 --- a/Examples/Python/python/acts/examples/reconstruction.py +++ b/Examples/Python/python/acts/examples/reconstruction.py @@ -679,6 +679,7 @@ def addCKFTracks( inputSourceLinks="sourcelinks", inputInitialTrackParameters="estimatedparameters", outputTrajectories="trajectories", + outputTrackParameters="fittedTrackParameters", findTracks=acts.examples.TrackFindingAlgorithm.makeTrackFinderFunction( trackingGeometry, field ), @@ -838,7 +839,7 @@ def addVertexFitting( field, outputDirRoot: Optional[Union[Path, str]] = None, associatedParticles: str = "particles_input", - trackParameters: str = "estimatedparameters", + trackParameters: str = "trackparameters", vertexFinder: VertexFinder = VertexFinder.Truth, logLevel: Optional[acts.logging.Level] = None, ): diff --git a/Examples/Python/src/TrackFinding.cpp b/Examples/Python/src/TrackFinding.cpp index 0730cb04517..242e5d1aa09 100644 --- a/Examples/Python/src/TrackFinding.cpp +++ b/Examples/Python/src/TrackFinding.cpp @@ -314,6 +314,7 @@ void addTrackFinding(Context& ctx) { ACTS_PYTHON_MEMBER(inputSourceLinks); ACTS_PYTHON_MEMBER(inputInitialTrackParameters); ACTS_PYTHON_MEMBER(outputTrajectories); + ACTS_PYTHON_MEMBER(outputTrackParameters); ACTS_PYTHON_MEMBER(findTracks); ACTS_PYTHON_MEMBER(measurementSelectorCfg); ACTS_PYTHON_STRUCT_END(); diff --git a/Examples/Scripts/Python/full_chain_odd.py b/Examples/Scripts/Python/full_chain_odd.py index d240b0122a9..8abe4855bb3 100755 --- a/Examples/Scripts/Python/full_chain_odd.py +++ b/Examples/Scripts/Python/full_chain_odd.py @@ -33,7 +33,6 @@ ) from acts.examples.reconstruction import ( addSeeding, - TruthSeedRanges, addCKFTracks, CKFPerformanceConfig, addVertexFitting, @@ -46,7 +45,7 @@ s, MomentumConfig(1.0 * u.GeV, 10.0 * u.GeV, True), EtaConfig(-3.0, 3.0, True), - ParticleConfig(1, acts.PdgParticle.eMuon, True), + ParticleConfig(2, acts.PdgParticle.eMuon, True), rnd=rnd, ) s = addFatras( @@ -68,10 +67,8 @@ s, trackingGeometry, field, - TruthSeedRanges(pt=(1.0 * u.GeV, None), eta=(-2.7, 2.7), nHits=(9, None)), geoSelectionConfigFile=oddSeedingSel, outputDirRoot=outputDir, - initialVarInflation=[100, 100, 100, 100, 100, 100], ) s = addCKFTracks( s, @@ -80,10 +77,22 @@ CKFPerformanceConfig(ptMin=400.0 * u.MeV, nMeasurementsMin=6), outputDirRoot=outputDir, ) +s.addAlgorithm( + acts.examples.TrackSelector( + level=acts.logging.INFO, + inputTrackParameters="fittedTrackParameters", + outputTrackParameters="trackparameters", + outputTrackIndices="outputTrackIndices", + removeNeutral=True, + absEtaMax=2.5, + loc0Max=4.0 * u.mm, # rho max + ptMin=500 * u.MeV, + ) +) s = addVertexFitting( s, field, - vertexFinder=VertexFinder.Truth, + vertexFinder=VertexFinder.Iterative, outputDirRoot=outputDir, )