26 return !
cache.multiComponentState.empty();
31doStateAssembly(
Cache&&
cache,
const double newWeight)
33 if (!isStateValid(
cache)) {
36 const size_t cacheSize =
cache.multiComponentState.size();
37 if (
cache.validWeightSum <= 0.) {
38 if (!
cache.multiComponentState.empty()) {
39 const double fixedWeights = 1. /
static_cast<double>(cacheSize);
40 for (
auto& component :
cache.multiComponentState) {
41 component.weight = fixedWeights;
45 std::move(
cache.multiComponentState);
51 std::move(
cache.multiComponentState);
52 const double scalingFactor =
53 cache.validWeightSum > 0. ? newWeight /
cache.validWeightSum : 1.;
55 component.weight *= scalingFactor;
66 if (!isStateValid(
cache)) {
71 double const den =
cache.validWeightSum +
cache.invalidWeightSum;
72 double const validWeightFraction = den > 0 ?
cache.validWeightSum / den : 0;
73 if (
cache.invalidWeightSum > 0. &&
79 cache.multiComponentState.begin(),
cache.multiComponentState.end(),
81 return x.weight > y.weight;
84 double const totalWeight(
cache.validWeightSum +
cache.invalidWeightSum);
85 if (totalWeight != 0.) {
89 const double minimumWeight =
91 std::numeric_limits<double>::min());
95 auto lower_than = std::upper_bound(
96 cache.multiComponentState.begin(),
cache.multiComponentState.end(),
102 auto lower_than_reverse = std::make_reverse_iterator(lower_than);
103 for (
auto itr =
cache.multiComponentState.rbegin();
104 itr != lower_than_reverse;
106 cache.multiComponentState.erase(itr.base() - 1);
110 if (!isStateValid(
cache)) {
123 if (!prepareStateForAssembly(
cache)) {
126 double totalWeight =
cache.validWeightSum;
127 if (
cache.invalidWeightSum > 0. ||
cache.validWeightSum <= 0.) {
128 totalWeight =
cache.validWeightSum +
cache.invalidWeightSum;
131 return doStateAssembly(std::move(
cache), totalWeight);
Definition of component parameters for use in a mixture of many components. In this regime each track...
Helper struct representing a cache of the Multicomponent state under assembly.
MultiComponentState assembledState(MultiComponentStateAssembler::Cache &&cache)
Method to return the cached state object - it performs a reweighting before returning the object base...
std::vector< ComponentParameters > MultiComponentState
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
static constexpr double minimumFractionalWeight
static constexpr double minimumValidFraction