Belle II Software development
ChooseableFilter.dcl.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/filters/base/FilterFactory.fwd.h>
11
12#include <tracking/trackFindingCDC/filters/base/FilterParamMap.h>
13
14#include <tracking/trackFindingCDC/numerics/Weight.h>
15
16#include <string>
17
18#include <memory>
19
20#include <vector>
21
22namespace Belle2 {
27 class ModuleParamList;
28
29 namespace TrackFindingCDC {
31 template <class AFilter>
32 class Chooseable : public AFilter {
33
34 private:
36 using Super = AFilter;
37
38 public:
40 using Object = typename AFilter::Object;
41
43 using Super::operator();
44
45 public:
47 explicit Chooseable(std::unique_ptr<FilterFactory<AFilter>> filterFactory);
48
50 Chooseable(std::unique_ptr<FilterFactory<AFilter>> filterFactory,
51 const std::string& filterName);
52
54 void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) final;
55
57 void initialize() override;
58
60 bool needsTruthInformation() override;
61
70 Weight operator()(const Object& object) final;
71
73 Weight operator()(const Object& object) const;
74
76 virtual std::vector<float> operator()(const std::vector <Object*>& objs) override;
77
78 public:
80 std::string getFilterName() const
81 {
82 return m_param_filterName;
83 }
84
85 private:
87 std::string m_param_filterName;
88
91 // std::map<std::string, FilterParamVariant> m_param_filterParameters;
92
94 std::unique_ptr<FilterFactory<AFilter> > m_filterFactory;
95
97 std::unique_ptr<AFilter> m_filter;
98 };
99
105 template <class AFilterFactory>
107 : public Chooseable<typename AFilterFactory::CreatedFilter> {
108
109 private:
112
113 public:
116
118 explicit ChooseableFilter(const std::string& filterName);
119 };
120 }
122}
The Module parameter list class.
Convenvience wrapper to setup a Chooseable filter from a specific factory object.
ChooseableFilter()
Constructor of the chooseable filter.
Filter can delegate to a filter chosen and set up at run time by parameters.
void initialize() override
Initialize before event processing.
std::unique_ptr< FilterFactory< AFilter > > m_filterFactory
Filter factor to construct a chosen filter.
bool needsTruthInformation() override
Indicates if the filter requires Monte Carlo information.
AFilter Super
Type of the base class.
std::unique_ptr< AFilter > m_filter
Chosen filter.
std::string m_param_filterName
Parameters : Name of the selected filter.
std::string getFilterName() const
Return name of the selected filter.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
typename AFilter::Object Object
Type of the object to be analysed.
Weight operator()(const Object &object) final
Function to evaluate the object.
FilterParamMap m_param_filterParameters
Parameter: Parameter keys and values to be forwarded to the chosen filter.
Factory that can create appropriate filter instances from a name.
Variant of types allowed to be forwarded to a filter selected at runtime.
Abstract base class for different kinds of events.