Belle II Software  release-08-01-10
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 #include <memory>
18 
19 namespace Belle2 {
24  class ModuleParamList;
25 
26  namespace TrackFindingCDC {
28  template <class AFilter>
29  class Chooseable : public AFilter {
30 
31  private:
33  using Super = AFilter;
34 
35  public:
37  using Object = typename AFilter::Object;
38 
39  public:
41  explicit Chooseable(std::unique_ptr<FilterFactory<AFilter>> filterFactory);
42 
44  Chooseable(std::unique_ptr<FilterFactory<AFilter>> filterFactory,
45  const std::string& filterName);
46 
48  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) final;
49 
51  void initialize() override;
52 
54  bool needsTruthInformation() override;
55 
64  Weight operator()(const Object& object) final;
65 
67  Weight operator()(const Object& object) const;
68 
69  public:
71  std::string getFilterName() const
72  {
73  return m_param_filterName;
74  }
75 
76  private:
78  std::string m_param_filterName;
79 
82  // std::map<std::string, FilterParamVariant> m_param_filterParameters;
83 
85  std::unique_ptr<FilterFactory<AFilter> > m_filterFactory;
86 
88  std::unique_ptr<AFilter> m_filter;
89  };
90 
96  template <class AFilterFactory>
98  : public Chooseable<typename AFilterFactory::CreatedFilter> {
99 
100  private:
103 
104  public:
107 
109  explicit ChooseableFilter(const std::string& filterName);
110  };
111  }
113 }
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.
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< 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 apropriate 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.