Skip to content

Commit

Permalink
activate
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminhuth committed Dec 18, 2024
1 parent 2bb167c commit 6376e64
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CI/physmon/workflows/physmon_trackfitting_kf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
field=setup.field,
digiConfigFile=setup.digiConfig,
outputDir=tp,
reverseFilteringMomThreshold=float("inf"),
reverseFilteringCovarianceScaling=100.0,
s=s,
)

Expand Down
14 changes: 13 additions & 1 deletion Core/include/Acts/TrackFitting/GaussianSumFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,23 @@ struct GaussianSumFitter {
: sParameters.referenceSurface();

const auto& params = *fwdGsfResult.lastMeasurementState;
std::vector<
std::tuple<double, BoundVector, std::optional<BoundSquareMatrix>>>
inflatedParamVector;
for (auto& [w, p, cov] : params.components()) {
inflatedParamVector.emplace_back(
w, p, cov.value() * options.reverseFilteringCovarianceScaling);
}

MultiComponentBoundTrackParameters inflatedParams(
params.referenceSurface().getSharedPtr(),
std::move(inflatedParamVector), params.particleHypothesis());

auto state =
m_propagator.template makeState<MultiComponentBoundTrackParameters,
decltype(bwdPropOptions),
MultiStepperSurfaceReached>(
params, target, bwdPropOptions);
inflatedParams, target, bwdPropOptions);

assert(
(fwdGsfResult.lastMeasurementTip != MultiTrajectoryTraits::kInvalid &&
Expand Down
2 changes: 2 additions & 0 deletions Core/include/Acts/TrackFitting/GsfOptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ struct GsfOptions {

bool disableAllMaterialHandling = false;

double reverseFilteringCovarianceScaling = 1.0;

std::string_view finalMultiComponentStateColumn = "";

ComponentMergeMethod componentMergeMethod = ComponentMergeMethod::eMaxWeight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ std::shared_ptr<TrackFitterFunction> makeKalmanFitterFunction(
std::shared_ptr<const Acts::MagneticFieldProvider> magneticField,
bool multipleScattering = true, bool energyLoss = true,
double reverseFilteringMomThreshold = 0.0,
double reverseFilteringCovarianceScaling = 1.0,
Acts::FreeToBoundCorrection freeToBoundCorrection =
Acts::FreeToBoundCorrection(),
const Acts::Logger& logger = *Acts::getDefaultLogger("Kalman",
Expand All @@ -89,14 +90,16 @@ enum class MixtureReductionAlgorithm { weightCut, KLDistance };
/// parameters and covariance
/// @param mixtureReductionAlgorithm How to reduce the number of components
/// in a mixture
/// @param reverseFilteringCovarianceScaling How the covariance matrices are
/// inflated before the reverse filtering pass
/// @param logger a logger instance
std::shared_ptr<TrackFitterFunction> makeGsfFitterFunction(
std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry,
std::shared_ptr<const Acts::MagneticFieldProvider> magneticField,
BetheHeitlerApprox betheHeitlerApprox, std::size_t maxComponents,
double weightCutoff, Acts::ComponentMergeMethod componentMergeMethod,
MixtureReductionAlgorithm mixtureReductionAlgorithm,
const Acts::Logger& logger);
double reverseFilteringCovarianceScaling, const Acts::Logger& logger);

/// Makes a fitter function object for the Global Chi Square Fitter (GX2F)
///
Expand Down
7 changes: 6 additions & 1 deletion Examples/Algorithms/TrackFitting/src/GsfFitterFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct GsfFitterFunctionImpl final : public ActsExamples::TrackFitterFunction {
MixtureReductionAlgorithm::KLDistance;
Acts::ComponentMergeMethod mergeMethod =
Acts::ComponentMergeMethod::eMaxWeight;
double reverseFilteringCovarianceScaling = 0.0;

IndexSourceLink::SurfaceAccessor m_slSurfaceAccessor;

Expand Down Expand Up @@ -115,6 +116,8 @@ struct GsfFitterFunctionImpl final : public ActsExamples::TrackFitterFunction {
gsfOptions.abortOnError = abortOnError;
gsfOptions.disableAllMaterialHandling = disableAllMaterialHandling;
gsfOptions.componentMergeMethod = mergeMethod;
gsfOptions.reverseFilteringCovarianceScaling =
reverseFilteringCovarianceScaling;

gsfOptions.extensions.calibrator.connect<&calibrator_t::calibrate>(
&calibrator);
Expand Down Expand Up @@ -195,7 +198,7 @@ std::shared_ptr<TrackFitterFunction> ActsExamples::makeGsfFitterFunction(
BetheHeitlerApprox betheHeitlerApprox, std::size_t maxComponents,
double weightCutoff, Acts::ComponentMergeMethod componentMergeMethod,
MixtureReductionAlgorithm mixtureReductionAlgorithm,
const Acts::Logger& logger) {
double reverseFilteringCovarianceScaling, const Acts::Logger& logger) {
// Standard fitter
MultiStepper stepper(magneticField, logger.cloneWithSuffix("Step"));
const auto& geo = *trackingGeometry;
Expand Down Expand Up @@ -229,6 +232,8 @@ std::shared_ptr<TrackFitterFunction> ActsExamples::makeGsfFitterFunction(
fitterFunction->weightCutoff = weightCutoff;
fitterFunction->mergeMethod = componentMergeMethod;
fitterFunction->reductionAlg = mixtureReductionAlgorithm;
fitterFunction->reverseFilteringCovarianceScaling =
reverseFilteringCovarianceScaling;

return fitterFunction;
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct KalmanFitterFunctionImpl final : public TrackFitterFunction {
Acts::GainMatrixUpdater kfUpdater;
Acts::GainMatrixSmoother kfSmoother;
SimpleReverseFilteringLogic reverseFilteringLogic;

double reverseFilteringCovarianceScaling;
bool multipleScattering = false;
bool energyLoss = false;
Acts::FreeToBoundCorrection freeToBoundCorrection;
Expand Down Expand Up @@ -114,6 +114,8 @@ struct KalmanFitterFunctionImpl final : public TrackFitterFunction {
kfOptions.freeToBoundCorrection = freeToBoundCorrection;
kfOptions.extensions.calibrator.connect<&calibrator_t::calibrate>(
&calibrator);
kfOptions.reversedFilteringCovarianceScaling =
reverseFilteringCovarianceScaling;

if (options.doRefit) {
kfOptions.extensions.surfaceAccessor
Expand Down Expand Up @@ -159,6 +161,7 @@ ActsExamples::makeKalmanFitterFunction(
std::shared_ptr<const Acts::MagneticFieldProvider> magneticField,
bool multipleScattering, bool energyLoss,
double reverseFilteringMomThreshold,
double reverseFilteringCovarianceScaling,
Acts::FreeToBoundCorrection freeToBoundCorrection,
const Acts::Logger& logger) {
// Stepper should be copied into the fitters
Expand Down Expand Up @@ -191,6 +194,8 @@ ActsExamples::makeKalmanFitterFunction(
fitterFunction->reverseFilteringLogic.momentumThreshold =
reverseFilteringMomThreshold;
fitterFunction->freeToBoundCorrection = freeToBoundCorrection;
fitterFunction->reverseFilteringCovarianceScaling =
reverseFilteringCovarianceScaling;

return fitterFunction;
}
3 changes: 3 additions & 0 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,7 @@ def addKalmanTracks(
trackingGeometry: acts.TrackingGeometry,
field: acts.MagneticFieldProvider,
reverseFilteringMomThreshold: float = 0 * u.GeV,
reverseFilteringCovarianceScaling: float = 1.0,
inputProtoTracks: str = "truth_particle_tracks",
multipleScattering: bool = True,
energyLoss: bool = True,
Expand All @@ -1302,6 +1303,7 @@ def addKalmanTracks(
"multipleScattering": multipleScattering,
"energyLoss": energyLoss,
"reverseFilteringMomThreshold": reverseFilteringMomThreshold,
"reverseFilteringCovarianceScaling": reverseFilteringCovarianceScaling,
"freeToBoundCorrection": acts.examples.FreeToBoundCorrection(False),
"level": customLogLevel(),
}
Expand Down Expand Up @@ -1362,6 +1364,7 @@ def addTruthTrackingGsf(
"componentMergeMethod": acts.examples.ComponentMergeMethod.maxWeight,
"mixtureReductionAlgorithm": acts.examples.MixtureReductionAlgorithm.KLDistance,
"weightCutoff": 1.0e-4,
"reverseFilteringCovarianceScaling": 100.0,
"level": customLogLevel(),
}

Expand Down
25 changes: 13 additions & 12 deletions Examples/Python/src/TrackFitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,18 @@ void addTrackFitting(Context& ctx) {
std::shared_ptr<const Acts::MagneticFieldProvider> magneticField,
bool multipleScattering, bool energyLoss,
double reverseFilteringMomThreshold,
double reverseFilteringCovarianceScaling,
Acts::FreeToBoundCorrection freeToBoundCorrection,
Logging::Level level) {
return ActsExamples::makeKalmanFitterFunction(
trackingGeometry, magneticField, multipleScattering, energyLoss,
reverseFilteringMomThreshold, freeToBoundCorrection,
*Acts::getDefaultLogger("Kalman", level));
reverseFilteringMomThreshold, reverseFilteringCovarianceScaling,
freeToBoundCorrection, *Acts::getDefaultLogger("Kalman", level));
},
py::arg("trackingGeometry"), py::arg("magneticField"),
py::arg("multipleScattering"), py::arg("energyLoss"),
py::arg("reverseFilteringMomThreshold"),
py::arg("freeToBoundCorrection"), py::arg("level"));
"trackingGeometry"_a, "magneticField"_a, "multipleScattering"_a,
"energyLoss"_a, "reverseFilteringMomThreshold"_a,
"reverseFilteringCovarianceScaling"_a, "freeToBoundCorrection"_a,
"level"_a);

py::class_<MeasurementCalibrator, std::shared_ptr<MeasurementCalibrator>>(
mex, "MeasurementCalibrator");
Expand Down Expand Up @@ -108,17 +109,17 @@ void addTrackFitting(Context& ctx) {
BetheHeitlerApprox betheHeitlerApprox, std::size_t maxComponents,
double weightCutoff, Acts::ComponentMergeMethod componentMergeMethod,
ActsExamples::MixtureReductionAlgorithm mixtureReductionAlgorithm,
Logging::Level level) {
double reverseFilteringCovarianceScaling, Logging::Level level) {
return ActsExamples::makeGsfFitterFunction(
trackingGeometry, magneticField, betheHeitlerApprox,
maxComponents, weightCutoff, componentMergeMethod,
mixtureReductionAlgorithm,
mixtureReductionAlgorithm, reverseFilteringCovarianceScaling,
*Acts::getDefaultLogger("GSFFunc", level));
},
py::arg("trackingGeometry"), py::arg("magneticField"),
py::arg("betheHeitlerApprox"), py::arg("maxComponents"),
py::arg("weightCutoff"), py::arg("componentMergeMethod"),
py::arg("mixtureReductionAlgorithm"), py::arg("level"));
"trackingGeometry"_a, "magneticField"_a, "betheHeitlerApprox"_a,
"maxComponents"_a, "weightCutoff"_a, "componentMergeMethod"_a,
"mixtureReductionAlgorithm"_a, "reverseFilteringCovarianceScaling"_a,
"level"_a);

mex.def(
"makeGlobalChiSquareFitterFunction",
Expand Down
2 changes: 2 additions & 0 deletions Examples/Scripts/Python/truth_tracking_kalman.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def runTruthTrackingKalman(
inputHitsPath: Optional[Path] = None,
decorators=[],
reverseFilteringMomThreshold=0 * u.GeV,
reverseFilteringCovarianceScaling=1,
s: acts.examples.Sequencer = None,
):
from acts.examples.simulation import (
Expand Down Expand Up @@ -122,6 +123,7 @@ def runTruthTrackingKalman(
trackingGeometry,
field,
reverseFilteringMomThreshold,
reverseFilteringCovarianceScaling,
)

s.addAlgorithm(
Expand Down

0 comments on commit 6376e64

Please sign in to comment.