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/trackingUtilities/filters/base/FilterFactory.fwd.h>
11
12#include <tracking/trackingUtilities/filters/base/FilterParamMap.h>
13
14#include <framework/core/ModuleParamList.h>
15
16#include <tracking/trackingUtilities/numerics/Weight.h>
17
18#include <string>
19
20#include <memory>
21
22#include <vector>
23
24namespace Belle2 {
29
30 namespace TrackingUtilities {
32 template <class AFilter>
33 class Chooseable : public AFilter {
34
35 private:
37 using Super = AFilter;
38
39 public:
41 using Object = typename AFilter::Object;
42
44 using Super::operator();
45
46 public:
48 explicit Chooseable(std::unique_ptr<FilterFactory<AFilter>> filterFactory);
49
51 Chooseable(std::unique_ptr<FilterFactory<AFilter>> filterFactory,
52 const std::string& filterName);
53
55 void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) final;
56
58 void initialize() override;
59
61 void beginRun() override;
62
64 bool needsTruthInformation() override;
65
74 Weight operator()(const Object& object) final;
75
77 Weight operator()(const Object& object) const;
78
80 virtual std::vector<float> operator()(const std::vector <Object*>& objs) override;
81
82 public:
84 const std::string& getFilterName() const
85 {
86 return m_param_filterName;
87 }
88
90 std::unique_ptr<AFilter>& getFilterPtr() { return m_filter; }
91
92 private:
94 std::string m_param_filterName;
95
98 // std::map<std::string, FilterParamVariant> m_param_filterParameters;
99
101 std::unique_ptr<FilterFactory<AFilter> > m_filterFactory;
102
104 std::unique_ptr<AFilter> m_filter;
105
108 };
109
115 template <class AFilterFactory>
117 : public Chooseable<typename AFilterFactory::CreatedFilter> {
118
119 private:
122
123 public:
126
128 explicit ChooseableFilter(const std::string& filterName);
129 };
130 }
132}
The Module parameter list class.
ChooseableFilter(const std::string &filterName)
Constructor of the chooseable filter taking the default filter name.
ChooseableFilter()
Constructor of the chooseable filter.
Chooseable< typename PXDResultFilterFactory::CreatedFilter > Super
Chooseable(std::unique_ptr< FilterFactory< AFilter > > filterFactory)
Setup the chooseable filter with available choices from the factory.
void initialize() override
Initialize before event processing.
std::unique_ptr< FilterFactory< typename AFilterFactory::CreatedFilter > > m_filterFactory
bool needsTruthInformation() override
Indicates if the filter requires Monte Carlo information.
Chooseable(std::unique_ptr< FilterFactory< AFilter > > filterFactory, const std::string &filterName)
Setup the chooseable filter with available choices from the factory and a default name.
AFilter Super
Type of the base class.
virtual std::vector< float > operator()(const std::vector< Object * > &objs) override
Evaluate the MVA method over a vector of objects. Returns float weight or NAN (when object is rejecte...
Weight operator()(const Object &object) const
Const version of operator.
std::unique_ptr< typename AFilterFactory::CreatedFilter > m_filter
std::unique_ptr< AFilter > & getFilterPtr()
need access to underlying filter to set parameters
void beginRun() override
beginRun needed to reassign parameters if changed
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.
const std::string & getFilterName() const
Return name of the selected 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.