Belle II Software development
FilterSelector.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackFindingCDC/findlets/base/Findlet.h>
11
12#include <tracking/trackFindingCDC/numerics/Weight.h>
13
14#include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
15#include <tracking/trackFindingCDC/utilities/Algorithms.h>
16
17#include <algorithm>
18#include <vector>
19#include <string>
20
21namespace Belle2 {
26 class ModuleParamList;
27 namespace TrackFindingCDC {
44 template <class ACollectorItem, class ACollectionItem, class AFilter>
46 public Findlet<WeightedRelation<ACollectorItem, const ACollectionItem>> {
47 public:
50
53
56 {
58 }
59
61 void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override
62 {
63 Super::exposeParameters(moduleParamList, prefix);
64 m_filter.exposeParameters(moduleParamList, prefix);
65 }
66
68 void apply(std::vector<WeightedRelationItem>& weightedRelations) override
69 {
70 for (WeightedRelationItem& weightedRelation : weightedRelations) {
71 const Weight weight = m_filter(weightedRelation);
72 weightedRelation.setWeight(weight);
73 }
74
75 const auto& weightIsNan = [](const WeightedRelationItem & item) {
76 return std::isnan(item.getWeight());
77 };
78
79 // Erase all items with a weight of NAN
80 erase_remove_if(weightedRelations, weightIsNan);
81
82 std::sort(weightedRelations.begin(), weightedRelations.end());
83 }
84
85 private:
87 AFilter m_filter;
88 };
89 }
91}
The Module parameter list class.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Selector to remove all weighted relations, where a definable Filter gives NaN as a result.
void apply(std::vector< WeightedRelationItem > &weightedRelations) override
Main function of the class: calculate the filter result and remove all relations, where the filter re...
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the filter.
AFilter m_filter
The filter to use.
FilterSelector()
Add the chosen filter as a process signal listener.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition: Findlet.h:26
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Forward prefixed parameters of this findlet to the module parameter list.
Definition: Findlet.h:69
Type for two related objects with a weight.
Abstract base class for different kinds of events.