-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-volume-agnostic-material-interaction
- Loading branch information
Showing
9 changed files
with
140 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2021 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 | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#pragma once | ||
|
||
#include "Acts/Surfaces/Surface.hpp" | ||
#include "Acts/TrackFitting/GsfOptions.hpp" | ||
|
||
namespace Acts { | ||
|
||
void reduceMixtureWithKLDistance( | ||
std::vector<Acts::Experimental::GsfComponent> &cmpCache, | ||
std::size_t maxCmpsAfterMerge, const Surface &surface); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ target_sources( | |
GsfError.cpp | ||
GsfUtils.cpp | ||
BetheHeitlerApprox.cpp | ||
GsfMixtureReduction.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2023 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 | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#include "Acts/TrackFitting/GsfMixtureReduction.hpp" | ||
|
||
#include "Acts/TrackFitting/detail/SymmetricKlDistanceMatrix.hpp" | ||
|
||
template <typename proj_t, typename angle_desc_t> | ||
void reduceWithKLDistanceImpl( | ||
std::vector<Acts::Experimental::GsfComponent> &cmpCache, | ||
std::size_t maxCmpsAfterMerge, const proj_t &proj, | ||
const angle_desc_t &desc) { | ||
Acts::detail::SymmetricKLDistanceMatrix distances(cmpCache, proj); | ||
|
||
auto remainingComponents = cmpCache.size(); | ||
|
||
while (remainingComponents > maxCmpsAfterMerge) { | ||
const auto [minI, minJ] = distances.minDistancePair(); | ||
|
||
// Set one component and compute associated distances | ||
cmpCache[minI] = | ||
mergeComponents(cmpCache[minI], cmpCache[minJ], proj, desc); | ||
distances.recomputeAssociatedDistances(minI, cmpCache, proj); | ||
|
||
// Set weight of the other component to -1 so we can remove it later and | ||
// mask its distances | ||
proj(cmpCache[minJ]).weight = -1.0; | ||
distances.maskAssociatedDistances(minJ); | ||
|
||
remainingComponents--; | ||
} | ||
|
||
// Remove all components which are labeled with weight -1 | ||
std::sort(cmpCache.begin(), cmpCache.end(), | ||
[&](const auto &a, const auto &b) { | ||
return proj(a).weight < proj(b).weight; | ||
}); | ||
cmpCache.erase( | ||
std::remove_if(cmpCache.begin(), cmpCache.end(), | ||
[&](const auto &a) { return proj(a).weight == -1.0; }), | ||
cmpCache.end()); | ||
|
||
assert(cmpCache.size() == maxCmpsAfterMerge && "size mismatch"); | ||
} | ||
|
||
namespace Acts { | ||
|
||
void reduceMixtureWithKLDistance( | ||
std::vector<Acts::Experimental::GsfComponent> &cmpCache, | ||
std::size_t maxCmpsAfterMerge, const Surface &surface) { | ||
if (cmpCache.size() <= maxCmpsAfterMerge) { | ||
return; | ||
} | ||
|
||
auto proj = [](auto &a) -> decltype(auto) { return a; }; | ||
|
||
// We must differ between surface types, since there can be different | ||
// local coordinates | ||
detail::angleDescriptionSwitch(surface, [&](const auto &desc) { | ||
reduceWithKLDistanceImpl(cmpCache, maxCmpsAfterMerge, proj, desc); | ||
}); | ||
} | ||
|
||
} // namespace Acts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.