Skip to content

Commit

Permalink
refactor(gx2f): clean up logging before material PR (acts-project#3294)
Browse files Browse the repository at this point in the history
blocked by:
- acts-project#3293
  • Loading branch information
AJPfleger authored Jun 15, 2024
1 parent e1a76b3 commit 06c2b63
Showing 1 changed file with 28 additions and 47 deletions.
75 changes: 28 additions & 47 deletions Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2023 CERN for the benefit of the Acts project
// Copyright (C) 2023-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 @@ -56,7 +56,7 @@ constexpr TrackStatePropMask trackStateMask = TrackStatePropMask::Predicted |
TrackStatePropMask::Calibrated;
} // namespace Gx2fConstants

/// Extension struct which holds delegates to customize the KF behavior
/// Extension struct which holds delegates to customise the GX2F behaviour
template <typename traj_t>
struct Gx2FitterExtensions {
using TrackStateProxy = typename MultiTrajectory<traj_t>::TrackStateProxy;
Expand Down Expand Up @@ -243,13 +243,17 @@ void addToGx2fSums(BoundMatrix& aMatrix, BoundVector& bVector, double& chi2sum,
const BoundMatrix& jacobianFromStart,
const track_state_t& trackState, const Logger& logger) {
BoundVector predicted = trackState.predicted();

ActsVector<kMeasDim> measurement = trackState.template calibrated<kMeasDim>();

ActsSquareMatrix<kMeasDim> covarianceMeasurement =
trackState.template calibratedCovariance<kMeasDim>();

ActsMatrix<kMeasDim, eBoundSize> projector =
trackState.projector().template topLeftCorner<kMeasDim, eBoundSize>();

ActsMatrix<kMeasDim, eBoundSize> projJacobian = projector * jacobianFromStart;

ActsMatrix<kMeasDim, 1> projPredicted = projector * predicted;

ActsVector<kMeasDim> residual = measurement - projPredicted;
Expand Down Expand Up @@ -445,26 +449,23 @@ class Gx2Fitter {
auto surface = navigator.currentSurface(state.navigation);
if (surface != nullptr) {
++result.surfaceCount;
ACTS_VERBOSE("Surface " << surface->geometryId() << " detected.");
const GeometryIdentifier geoId = surface->geometryId();
ACTS_DEBUG("Surface " << geoId << " detected.");

// Found material
if (surface->surfaceMaterial() != nullptr) {
ACTS_DEBUG(" The surface contains material.");
}

// Check if we have a measurement surface
if (auto sourcelink_it = inputMeasurements->find(surface->geometryId());
if (auto sourcelink_it = inputMeasurements->find(geoId);
sourcelink_it != inputMeasurements->end()) {
ACTS_VERBOSE("Measurement surface " << surface->geometryId()
<< " detected.");
ACTS_DEBUG(" The surface contains a measurement.");

// Transport the covariance to the surface
stepper.transportCovarianceToBound(state.stepping, *surface,
freeToBoundCorrection);

ACTS_VERBOSE(
"Actor - indices before processing:"
<< "\n "
<< "result.lastMeasurementIndex: " << result.lastMeasurementIndex
<< "\n "
<< "result.lastTrackIndex: " << result.lastTrackIndex << "\n "
<< "result.fittedStates->size(): " << result.fittedStates->size())

// TODO generalize the update of the currentTrackIndex
auto& fittedStates = *result.fittedStates;

Expand All @@ -473,7 +474,7 @@ class Gx2Fitter {
typename traj_t::TrackStateProxy trackStateProxy =
fittedStates.makeTrackState(Gx2fConstants::trackStateMask,
result.lastTrackIndex);
std::size_t currentTrackIndex = trackStateProxy.index();
const std::size_t currentTrackIndex = trackStateProxy.index();

// Set the trackStateProxy components with the state from the ongoing
// propagation
Expand Down Expand Up @@ -512,15 +513,7 @@ class Gx2Fitter {
typeFlags.set(TrackStateFlag::MeasurementFlag);
// We count the processed measurement
++result.processedMeasurements;
ACTS_VERBOSE("Actor - indices after processing, before over writing:"
<< "\n "
<< "result.lastMeasurementIndex: "
<< result.lastMeasurementIndex << "\n "
<< "trackStateProxy.index(): " << trackStateProxy.index()
<< "\n "
<< "result.lastTrackIndex: " << result.lastTrackIndex
<< "\n "
<< "currentTrackIndex: " << currentTrackIndex)

result.lastMeasurementIndex = currentTrackIndex;
result.lastTrackIndex = currentTrackIndex;

Expand All @@ -542,12 +535,9 @@ class Gx2Fitter {
<< " detected.");

// We only create track states here if there is already a measurement
// detected or if the surface has material (no holes before the first
// measurement)
if (result.measurementStates > 0
// || surface->surfaceMaterial() != nullptr
) {
ACTS_VERBOSE("Handle hole.");
// detected (no holes before the first measurement)
if (result.measurementStates > 0) {
ACTS_DEBUG(" Handle hole.");

auto& fittedStates = *result.fittedStates;

Expand All @@ -556,7 +546,8 @@ class Gx2Fitter {
typename traj_t::TrackStateProxy trackStateProxy =
fittedStates.makeTrackState(Gx2fConstants::trackStateMask,
result.lastTrackIndex);
std::size_t currentTrackIndex = trackStateProxy.index();
const std::size_t currentTrackIndex = trackStateProxy.index();

{
// Set the trackStateProxy components with the state from the
// ongoing propagation
Expand Down Expand Up @@ -597,16 +588,6 @@ class Gx2Fitter {
}
}

ACTS_VERBOSE(
"Actor - indices after processing, before over writing:"
<< "\n "
<< "result.lastMeasurementIndex: "
<< result.lastMeasurementIndex << "\n "
<< "trackStateProxy.index(): " << trackStateProxy.index()
<< "\n "
<< "result.lastTrackIndex: " << result.lastTrackIndex
<< "\n "
<< "currentTrackIndex: " << currentTrackIndex)
result.lastTrackIndex = currentTrackIndex;

if (trackStateProxy.typeFlags().test(TrackStateFlag::HoleFlag)) {
Expand All @@ -616,7 +597,7 @@ class Gx2Fitter {

++result.processedStates;
} else {
ACTS_VERBOSE("Ignoring hole, because no preceding measurements.");
ACTS_DEBUG(" Ignoring hole, because no preceding measurements.");
}

if (surface->surfaceMaterial() != nullptr) {
Expand All @@ -626,12 +607,12 @@ class Gx2Fitter {
// MaterialUpdateStage::FullUpdate);
}
} else {
ACTS_INFO("Actor: This case is not implemented yet")
ACTS_INFO("Surface " << geoId << " has no measurement/material/hole.")
}
}
ACTS_DEBUG("result.processedMeasurements: "
<< result.processedMeasurements << "\n"
<< "inputMeasurements.size(): " << inputMeasurements->size())
ACTS_VERBOSE("result.processedMeasurements: "
<< result.processedMeasurements << "\n"
<< "inputMeasurements.size(): " << inputMeasurements->size())
if (result.processedMeasurements >= inputMeasurements->size()) {
ACTS_INFO("Actor: finish: all measurements found.");
result.finished = true;
Expand Down Expand Up @@ -693,7 +674,7 @@ class Gx2Fitter {
const -> std::enable_if_t<
!_isdn, Result<typename TrackContainer<track_container_t, traj_t,
holder_t>::TrackProxy>> {
// Preprocess Measurements (Sourcelinks -> map)
// Preprocess Measurements (SourceLinks -> 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)
Expand Down

0 comments on commit 06c2b63

Please sign in to comment.