Skip to content

Commit

Permalink
Merge branch 'main' into chore/pre-commit-all-the-things
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger authored Aug 27, 2024
2 parents 95ecacc + e03d106 commit 51dbaad
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 69 deletions.
Binary file not shown.
131 changes: 62 additions & 69 deletions Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,10 @@ class Gx2Fitter {
++result.surfaceCount;
const GeometryIdentifier geoId = surface->geometryId();
ACTS_DEBUG("Surface " << geoId << " detected.");

bool doMaterial =
multipleScattering && surface->surfaceMaterial() != nullptr;
const bool surfaceIsSensitive =
(surface->associatedDetectorElement() != nullptr);
const bool surfaceHasMaterial = (surface->surfaceMaterial() != nullptr);
const bool doMaterial = multipleScattering && surfaceHasMaterial;

// Found material
if (doMaterial) {
Expand Down Expand Up @@ -519,7 +520,7 @@ class Gx2Fitter {
// Get and set the type flags
auto typeFlags = trackStateProxy.typeFlags();
typeFlags.set(TrackStateFlag::ParameterFlag);
if (surface->surfaceMaterial() != nullptr) {
if (surfaceHasMaterial) {
typeFlags.set(TrackStateFlag::MaterialFlag);
}

Expand Down Expand Up @@ -549,8 +550,7 @@ class Gx2Fitter {
ACTS_DEBUG(
" The surface contains no measurement, but material and maybe "
"a hole.");
} else if (surface->associatedDetectorElement() != nullptr ||
surface->surfaceMaterial() != nullptr) {
} else if (surfaceIsSensitive || surfaceHasMaterial) {
// Here we handle holes. If material hasn't been handled before
// (because multipleScattering is turned off), we will also handle it
// here
Expand All @@ -564,75 +564,68 @@ class Gx2Fitter {
}

// We only create track states here if there is already a measurement
// detected (no holes before the first measurement)
if (result.measurementStates > 0) {
ACTS_DEBUG(" Handle hole.");

auto& fittedStates = *result.fittedStates;

// Add a <trackStateMask> TrackState entry multi trajectory. This
// allocates storage for all components, which we will set later.
typename traj_t::TrackStateProxy trackStateProxy =
fittedStates.makeTrackState(Gx2fConstants::trackStateMask,
result.lastTrackIndex);
const std::size_t currentTrackIndex = trackStateProxy.index();

{
// Set the trackStateProxy components with the state from the
// ongoing propagation
{
trackStateProxy.setReferenceSurface(surface->getSharedPtr());
// Bind the transported state to the current surface
auto res = stepper.boundState(state.stepping, *surface, false,
freeToBoundCorrection);
if (!res.ok()) {
result.result = res.error();
return;
}
const auto& [boundParams, jacobian, pathLength] = *res;

// Fill the track state
trackStateProxy.predicted() = boundParams.parameters();
trackStateProxy.predictedCovariance() = state.stepping.cov;

trackStateProxy.jacobian() = jacobian;
trackStateProxy.pathLength() = pathLength;
}

// Get and set the type flags
auto typeFlags = trackStateProxy.typeFlags();
typeFlags.set(TrackStateFlag::ParameterFlag);
if (surface->surfaceMaterial() != nullptr) {
typeFlags.set(TrackStateFlag::MaterialFlag);
}

// Set hole only, if we are on a sensitive surface
if (surface->associatedDetectorElement() != nullptr) {
ACTS_VERBOSE("Detected hole on " << surface->geometryId());
// If the surface is sensitive, set the hole type flag
typeFlags.set(TrackStateFlag::HoleFlag);
} else {
ACTS_VERBOSE("Detected in-sensitive surface "
<< surface->geometryId());
}
}
// detected (no holes before the first measurement) or if we encounter
// material
const bool precedingMeasurementExists =
(result.measurementStates > 0);
if (!precedingMeasurementExists && !surfaceHasMaterial) {
ACTS_DEBUG(
" Ignoring hole, because there are no preceding "
"measurements.");
return;
}

result.lastTrackIndex = currentTrackIndex;
auto& fittedStates = *result.fittedStates;

if (trackStateProxy.typeFlags().test(TrackStateFlag::HoleFlag)) {
// Count the missed surface
result.missedActiveSurfaces.push_back(surface);
// Add a <trackStateMask> TrackState entry multi trajectory. This
// allocates storage for all components, which we will set later.
typename traj_t::TrackStateProxy trackStateProxy =
fittedStates.makeTrackState(Gx2fConstants::trackStateMask,
result.lastTrackIndex);
const std::size_t currentTrackIndex = trackStateProxy.index();

// Set the trackStateProxy components with the state from the
// ongoing propagation
{
trackStateProxy.setReferenceSurface(surface->getSharedPtr());
// Bind the transported state to the current surface
auto res = stepper.boundState(state.stepping, *surface, false,
freeToBoundCorrection);
if (!res.ok()) {
result.result = res.error();
return;
}
const auto& [boundParams, jacobian, pathLength] = *res;

++result.processedStates;
} else {
ACTS_DEBUG(" Ignoring hole, because no preceding measurements.");
// Fill the track state
trackStateProxy.predicted() = boundParams.parameters();
trackStateProxy.predictedCovariance() = state.stepping.cov;

trackStateProxy.jacobian() = jacobian;
trackStateProxy.pathLength() = pathLength;
}

// Get and set the type flags
auto typeFlags = trackStateProxy.typeFlags();
typeFlags.set(TrackStateFlag::ParameterFlag);
if (surfaceHasMaterial) {
ACTS_DEBUG(" It is material.");
typeFlags.set(TrackStateFlag::MaterialFlag);
}

// Set hole only, if we are on a sensitive surface
if (surfaceIsSensitive && precedingMeasurementExists) {
ACTS_DEBUG(" It is a hole.");
typeFlags.set(TrackStateFlag::HoleFlag);
// Count the missed surface
result.missedActiveSurfaces.push_back(surface);
}

result.lastTrackIndex = currentTrackIndex;

++result.processedStates;
} else {
// It may contain material if we are not doing multiple scattering.
// But then it is irrelevant.
ACTS_DEBUG(
" The surface contains no measurement/(material)/hole.");
ACTS_DEBUG(" The surface contains no measurement/material/hole.");
}
}
}
Expand Down

0 comments on commit 51dbaad

Please sign in to comment.