10#include <tracking/trackFindingCDC/findlets/base/Findlet.h>
12#include <tracking/trackFindingCDC/numerics/WeightComperator.h>
14#include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
15#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
17#include <framework/core/ModuleParamList.h>
18#include <framework/logging/Logger.h>
25 namespace TrackFindingCDC {
43 template <
class ACollectorItem,
class ACollectionItem,
class AComparer = std::less<const ACollectionItem*>>
45 public Findlet<WeightedRelation<ACollectorItem, const ACollectionItem>> {
59 "Use only the found candidate, if it is the only one. Otherwise, use the best one.",
64 void apply(std::vector<WeightedRelationItem>& weightedRelations)
override
66 B2ASSERT(
"The relations need to be sorted for this selector!",
67 std::is_sorted(weightedRelations.begin(), weightedRelations.end()));
70 std::map<const ACollectionItem*, std::vector<WeightedRelationItem>, AComparer> collectionItemToMatchedMap;
73 collectionItemToMatchedMap[relation.getTo()].push_back(relation);
77 weightedRelations.clear();
79 for (
const auto& collectionItemToMatches : collectionItemToMatchedMap) {
80 const auto& matches = collectionItemToMatches.second;
82 const auto& bestMatch = std::min_element(matches.begin(), matches.end(),
GreaterWeight());
87 weightedRelations.push_back(*bestMatch);
91 std::sort(weightedRelations.begin(), weightedRelations.end());
The Module parameter list class.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Forward prefixed parameters of this findlet to the module parameter list.
Selector to remove all relations in the list, which share the same collection item - except one in ca...
void setUseOnlySingleBestCandidate(bool useOnlySingleBestCandidate)
Set the UseOnlySingleBestCandidate parameter (mostly for tests).
void apply(std::vector< WeightedRelationItem > &weightedRelations) override
Main function of this class doing the relation selection.
bool m_param_useOnlySingleBestCandidate
Whether to output only those relations, where the relation from collectio to collector items is injec...
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the useOnlySingleBestCandidate parameter to the module.
Type for two related objects with a weight.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.
Functor factory turning a binary functor and two functors into a new functor which executes the binar...