Belle II Software development
CutSelector.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 <framework/core/ModuleParamList.h>
13#include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
14#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15
16#include <algorithm>
17#include <cmath>
18#include <string>
19#include <vector>
20
21namespace Belle2 {
26 namespace TrackFindingCDC {
41 template <class ACollectorItem, class ACollectionItem>
43 public Findlet<WeightedRelation<ACollectorItem, const ACollectionItem>> {
44 public:
47
50
52 void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) override
53 {
54 Super::exposeParameters(moduleParamList, prefix);
55 moduleParamList->addParameter(prefixed(prefix, "cutValue"), m_param_cutValue,
56 "Value to cut at.",
58 }
59
61 void apply(std::vector<WeightedRelationItem>& weightedRelations) override
62 {
63 const auto& lessThanCutOrNaN = [this](const WeightedRelationItem & relationItem) {
64 return std::isnan(relationItem.getWeight()) or relationItem.getWeight() < m_param_cutValue;
65 };
66
67 // Erase all items with a weight of NAN
68 weightedRelations.erase(std::remove_if(weightedRelations.begin(),
69 weightedRelations.end(),
70 lessThanCutOrNaN),
71 weightedRelations.end());
72 }
73
75 void setCutValue(Weight cutValue)
76 {
77 m_param_cutValue = cutValue;
78 }
79
80 private:
82 Weight m_param_cutValue = NAN;
83 };
84 }
86}
The Module parameter list class.
Selector to remove all weighted relations with a weight below a certain cut value.
Definition: CutSelector.h:43
void apply(std::vector< WeightedRelationItem > &weightedRelations) override
Do the cut.
Definition: CutSelector.h:61
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the cut value to the module.
Definition: CutSelector.h:52
Weight m_param_cutValue
The cut value to use.
Definition: CutSelector.h:82
void setCutValue(Weight cutValue)
Function to set the cut value (mostly for tests).
Definition: CutSelector.h:75
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.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.