From 940032059ca28b3b6a9831a84d16413764ed0bdd Mon Sep 17 00:00:00 2001 From: Carlo Varni <75478407+CarloVarni@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:02:33 +0100 Subject: [PATCH 1/2] fix: Wrong definition of the constraint (#3803) The concept definition was not generic enough to cover for cases with `N != 3ul` --- Core/include/Acts/Seeding/SeedFinder.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/include/Acts/Seeding/SeedFinder.hpp b/Core/include/Acts/Seeding/SeedFinder.hpp index cb5e7b06ff3..3e2e7ae8bad 100644 --- a/Core/include/Acts/Seeding/SeedFinder.hpp +++ b/Core/include/Acts/Seeding/SeedFinder.hpp @@ -38,11 +38,11 @@ concept GridBinCollection = std::ranges::random_access_range && std::same_as; -template -concept CollectionStoresSeedsTo = requires(Coll coll, external_t sp) { - Acts::detail::pushBackOrInsertAtEnd(coll, - Acts::Seed(sp, sp, sp)); -}; +template +concept CollectionStoresSeedsTo = + requires(collection_t coll, Acts::Seed seed) { + Acts::detail::pushBackOrInsertAtEnd(coll, seed); + }; enum class SpacePointCandidateType : short { eBottom, eTop }; From 27bfc2dcb842e1a470b3d6e9e5c6dcd6b246a8d7 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:30:45 +0100 Subject: [PATCH 2/2] refactor(gx2f): improve logging (#3801) --- .../TrackFitting/GlobalChiSquareFitter.hpp | 87 ++++++++++--------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index 3087285ec22..968843fa479 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -373,30 +373,30 @@ void addMeasurementToGx2fSums(Eigen::MatrixXd& aMatrixExtended, ACTS_VERBOSE( "Contributions in addMeasurementToGx2fSums:\n" - << "kMeasDim: " << kMeasDim << "\n" - << "predicted" << predicted.transpose() << "\n" - << "measurement: " << measurement.transpose() << "\n" - << "covarianceMeasurement:\n" + << " kMeasDim: " << kMeasDim << "\n" + << " predicted: " << predicted.transpose() << "\n" + << " measurement: " << measurement.transpose() << "\n" + << " covarianceMeasurement:\n" << covarianceMeasurement << "\n" - << "projector:\n" + << " projector:\n" << projector.eval() << "\n" - << "projJacobian:\n" + << " projJacobian:\n" << projJacobian.eval() << "\n" - << "projPredicted: " << (projPredicted.transpose()).eval() << "\n" - << "residual: " << (residual.transpose()).eval() << "\n" - << "extendedJacobian:\n" + << " projPredicted: " << (projPredicted.transpose()).eval() << "\n" + << " residual: " << (residual.transpose()).eval() << "\n" + << " extendedJacobian:\n" << extendedJacobian << "\n" - << "aMatrixMeas:\n" + << " aMatrix contribution:\n" << (projJacobian.transpose() * (*safeInvCovMeasurement) * projJacobian) .eval() << "\n" - << "bVectorMeas: " + << " bVector contribution: " << (residual.transpose() * (*safeInvCovMeasurement) * projJacobian).eval() << "\n" - << "chi2sumMeas: " + << " chi2sum contribution: " << (residual.transpose() * (*safeInvCovMeasurement) * residual)(0, 0) << "\n" - << "safeInvCovMeasurement:\n" + << " safeInvCovMeasurement:\n" << (*safeInvCovMeasurement)); return; @@ -460,8 +460,8 @@ void addMaterialToGx2fSums( ACTS_VERBOSE( "Contributions in addMaterialToGx2fSums:\n" - << " invCov: " << invCov << "\n" - << " sinThetaLoc: " << sinThetaLoc << "\n" + << " invCov: " << invCov << "\n" + << " sinThetaLoc: " << sinThetaLoc << "\n" << " deltaPosition: " << deltaPosition << "\n" << " Phi:\n" << " scattering angle: " << scatteringAngles[eBoundPhi] << "\n" @@ -825,13 +825,15 @@ class Gx2Fitter { if (doMaterial) { ACTS_DEBUG(" Update parameters with scattering angles."); const auto scatteringMapId = scatteringMap->find(geoId); - ACTS_VERBOSE(" scatteringAngles:\n" - << scatteringMapId->second.scatteringAngles() - << "\n boundParams before the update:\n" - << boundParams); + ACTS_VERBOSE( + " scatteringAngles: " + << scatteringMapId->second.scatteringAngles().transpose()); + ACTS_VERBOSE(" boundParams before the update: " + << boundParams.parameters().transpose()); boundParams.parameters() += scatteringMapId->second.scatteringAngles(); - ACTS_VERBOSE(" boundParams after the update:\n" << boundParams); + ACTS_VERBOSE(" boundParams after the update: " + << boundParams.parameters().transpose()); } // Fill the track state @@ -927,13 +929,15 @@ class Gx2Fitter { // multipleScattering and have material ACTS_DEBUG(" Update parameters with scattering angles."); const auto scatteringMapId = scatteringMap->find(geoId); - ACTS_VERBOSE(" scatteringAngles:\n" - << scatteringMapId->second.scatteringAngles() - << "\n boundParams before the update:\n" - << boundParams); + ACTS_VERBOSE( + " scatteringAngles: " + << scatteringMapId->second.scatteringAngles().transpose()); + ACTS_VERBOSE(" boundParams before the update: " + << boundParams.parameters().transpose()); boundParams.parameters() += scatteringMapId->second.scatteringAngles(); - ACTS_VERBOSE(" boundParams after the update:\n" << boundParams); + ACTS_VERBOSE(" boundParams after the update: " + << boundParams.parameters().transpose()); // Fill the track state trackStateProxy.smoothed() = boundParams.parameters(); @@ -1096,7 +1100,7 @@ class Gx2Fitter { requires(!isDirectNavigator) { // Preprocess Measurements (SourceLinks -> map) - // To be able to find measurements later, we put them into a map + // To be able to find measurements later, we put them into a map. // We need to copy input SourceLinks anyway, so the map can own them. ACTS_VERBOSE("Preparing " << std::distance(it, end) << " input measurements"); @@ -1107,7 +1111,6 @@ class Gx2Fitter { auto geoId = gx2fOptions.extensions.surfaceAccessor(sl)->geometryId(); inputMeasurements.emplace(geoId, std::move(sl)); } - ACTS_VERBOSE("inputMeasurements.size() = " << inputMeasurements.size()); // Store, if we want to do multiple scattering. We still need to pass this // option to the Actor. @@ -1154,21 +1157,21 @@ class Gx2Fitter { // track parameters. BoundMatrix fullCovariancePredicted = BoundMatrix::Identity(); - ACTS_VERBOSE("params:\n" << params); + ACTS_VERBOSE("Initial parameters: " << params.parameters().transpose()); /// Actual Fitting ///////////////////////////////////////////////////////// ACTS_DEBUG("Start to iterate"); // Iterate the fit and improve result. Abort after n steps or after - // convergence - // nUpdate is initialized outside to save its state for the track + // convergence. + // nUpdate is initialized outside to save its state for the track. std::size_t nUpdate = 0; for (nUpdate = 0; nUpdate < gx2fOptions.nUpdateMax; nUpdate++) { ACTS_DEBUG("nUpdate = " << nUpdate + 1 << "/" << gx2fOptions.nUpdateMax); // update params params.parameters() += deltaParams; - ACTS_VERBOSE("updated params:\n" << params); + ACTS_VERBOSE("Updated parameters: " << params.parameters().transpose()); // set up propagator and co Acts::GeometryContext geoCtx = gx2fOptions.geoContext; @@ -1228,9 +1231,8 @@ class Gx2Fitter { tipIndex = gx2fResult.lastMeasurementIndex; // It could happen, that no measurements were found. Then the track would - // be empty and the following operations would be invalid. - // Usually, this only happens during the first iteration, due to bad - // initial parameters. + // be empty and the following operations would be invalid. Usually, this + // only happens during the first iteration, due to bad initial parameters. if (tipIndex == Acts::MultiTrajectoryTraits::kInvalid) { ACTS_INFO("Did not find any measurements in nUpdate " << nUpdate + 1 << "/" << gx2fOptions.nUpdateMax); @@ -1307,12 +1309,11 @@ class Gx2Fitter { } // This check takes into account the evaluated dimensions of the - // measurements. To fit, we need at least NDF+1 measurements. However, - // we count n-dimensional measurements for n measurements, reducing the - // effective number of needed measurements. - // We might encounter the case, where we cannot use some (parts of a) - // measurements, maybe if we do not support that kind of measurement. This - // is also taken into account here. + // measurements. To fit, we need at least NDF+1 measurements. However, we + // count n-dimensional measurements for n measurements, reducing the + // effective number of needed measurements. We might encounter the case, + // where we cannot use some (parts of a) measurements, maybe if we do not + // support that kind of measurement. This is also taken into account here. // We skip the check during the first iteration, since we cannot guarantee // to hit all/enough measurement surfaces with the initial parameter // guess. @@ -1399,7 +1400,7 @@ class Gx2Fitter { oldChi2sum = chi2sum; } ACTS_DEBUG("Finished to iterate"); - ACTS_VERBOSE("final params:\n" << params); + ACTS_VERBOSE("Final parameters: " << params.parameters().transpose()); /// Finish Fitting ///////////////////////////////////////////////////////// ACTS_VERBOSE("Final scattering angles:"); @@ -1412,7 +1413,7 @@ class Gx2Fitter { << " )"); } - ACTS_VERBOSE("final covariance:\n" << fullCovariancePredicted); + ACTS_VERBOSE("Final covariance:\n" << fullCovariancePredicted); // Propagate again with the final covariance matrix. This is necessary to // obtain the propagated covariance for each state. @@ -1420,7 +1421,7 @@ class Gx2Fitter { // step, we will not ignore the boundary checks for measurement surfaces. We // want to create trackstates only on surfaces, that we actually hit. if (gx2fOptions.nUpdateMax > 0) { - ACTS_VERBOSE("final deltaParams:\n" << deltaParams); + ACTS_VERBOSE("Final delta parameters: " << deltaParams.transpose()); ACTS_VERBOSE("Propagate with the final covariance."); // update covariance params.covariance() = fullCovariancePredicted;