Belle II Software  release-05-02-19
ChooseableFilter.dcl.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/filters/base/FilterFactory.fwd.h>
13 
14 #include <tracking/trackFindingCDC/filters/base/FilterParamMap.h>
15 
16 #include <tracking/trackFindingCDC/numerics/Weight.h>
17 
18 #include <string>
19 #include <memory>
20 
21 namespace Belle2 {
26  class ModuleParamList;
27 
28  namespace TrackFindingCDC {
30  template <class AFilter>
31  class Chooseable : public AFilter {
32 
33  private:
35  using Super = AFilter;
36 
37  public:
39  using Object = typename AFilter::Object;
40 
41  public:
43  Chooseable(std::unique_ptr<FilterFactory<AFilter>> filterFactory);
44 
46  Chooseable(std::unique_ptr<FilterFactory<AFilter>> filterFactory,
47  const std::string& filterName);
48 
50  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix) final;
51 
53  void initialize() override;
54 
56  bool needsTruthInformation() override;
57 
66  Weight operator()(const Object& object) final;
67 
69  Weight operator()(const Object& object) const;
70 
71  public:
73  std::string getFilterName() const
74  {
75  return m_param_filterName;
76  }
77 
78  private:
80  std::string m_param_filterName;
81 
84  // std::map<std::string, FilterParamVariant> m_param_filterParameters;
85 
87  std::unique_ptr<FilterFactory<AFilter> > m_filterFactory;
88 
90  std::unique_ptr<AFilter> m_filter;
91  };
92 
98  template <class AFilterFactory>
99  class ChooseableFilter
100  : public Chooseable<typename AFilterFactory::CreatedFilter> {
101 
102  private:
105 
106  public:
109 
111  ChooseableFilter(const std::string& filterName);
112  };
113  }
115 }
Belle2::TrackFindingCDC::FilterFactory
Factory that can create apropriate filter instances from a name.
Definition: FilterFactory.dcl.h:35
Belle2::TrackFindingCDC::ChooseableFilter
Convenvience wrapper to setup a Chooseable filter from a specific factory object.
Definition: ChooseableFilter.dcl.h:107
Belle2::TrackFindingCDC::Chooseable::initialize
void initialize() override
Initialize before event processing.
Definition: ChooseableFilter.icc.h:80
Belle2::TrackFindingCDC::Chooseable::Chooseable
Chooseable(std::unique_ptr< FilterFactory< AFilter >> filterFactory)
Setup the chooseable filter with available choices from the factory.
Definition: ChooseableFilter.icc.h:39
Belle2::TrackFindingCDC::Chooseable::operator()
Weight operator()(const Object &object) final
Function to evaluate the object.
Definition: ChooseableFilter.icc.h:104
Belle2::TrackFindingCDC::Chooseable::m_filterFactory
std::unique_ptr< FilterFactory< AFilter > > m_filterFactory
Filter factor to construct a chosen filter.
Definition: ChooseableFilter.dcl.h:95
Belle2::TrackFindingCDC::Chooseable::Object
typename AFilter::Object Object
Type of the object to be analysed.
Definition: ChooseableFilter.dcl.h:47
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::Chooseable::getFilterName
std::string getFilterName() const
Return name of the selected filter.
Definition: ChooseableFilter.dcl.h:81
Belle2::TrackFindingCDC::Chooseable::m_param_filterName
std::string m_param_filterName
Parameters : Name of the selected filter.
Definition: ChooseableFilter.dcl.h:88
Belle2::TrackFindingCDC::Chooseable::needsTruthInformation
bool needsTruthInformation() override
Indicates if the filter requires Monte Carlo information.
Definition: ChooseableFilter.icc.h:98
Belle2::TrackFindingCDC::ChooseableFilter::ChooseableFilter
ChooseableFilter()
Constructor of the chooseable filter.
Definition: ChooseableFilter.icc.h:116
Belle2::TrackFindingCDC::Chooseable::m_filter
std::unique_ptr< AFilter > m_filter
Chosen filter.
Definition: ChooseableFilter.dcl.h:98
Belle2::TrackFindingCDC::Chooseable::m_param_filterParameters
FilterParamMap m_param_filterParameters
Parameter: Parameter keys and values to be forwarded to the chosen filter.
Definition: ChooseableFilter.dcl.h:91
Belle2::TrackFindingCDC::Chooseable::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
Definition: ChooseableFilter.icc.h:58
Belle2::TrackFindingCDC::Chooseable
Filter can delegate to a filter chosen and set up at run time by parameters.
Definition: ChooseableFilter.dcl.h:39
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::FilterParamMap
Variant of types allowed to be forwarded to a filter selected at runtime.
Definition: FilterParamMap.h:51
Belle2::TrackFindingCDC::Chooseable::Super
AFilter Super
Type of the base class.
Definition: ChooseableFilter.dcl.h:43