Belle II Software  release-05-02-19
FilterParamMap.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - 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 #include <tracking/trackFindingCDC/filters/base/FilterParamMap.h>
11 
12 #include <tracking/trackFindingCDC/utilities/ParameterVariant.h>
13 
14 #include <framework/core/ModuleParamList.templateDetails.h>
15 #include <framework/core/ModuleParam.templateDetails.h>
16 
17 using namespace Belle2;
18 using namespace TrackFindingCDC;
19 
20 namespace Belle2 {
25  namespace TrackFindingCDC {
26  using FilterParamVariant = boost::variant<bool, int, double, std::string, std::vector<std::string> >;
27  }
29 }
30 
31 // Instantiate the module parameter
33 
34 namespace Belle2 {
39  namespace TrackFindingCDC {
40 
43  public:
44  Impl() = default;
45 
47  void addParameter(ModuleParamList* moduleParamList, const std::string& name, const std::string& description)
48  {
49  moduleParamList->addParameter(name,
50  m_param_filterParameters,
51  description,
52  m_param_filterParameters);
53  }
54 
56  void assignTo(ModuleParamList* filterModuleParamList)
57  {
58  AssignParameterVisitor::update(filterModuleParamList, m_param_filterParameters);
59  }
60 
62  std::map<std::string, FilterParamVariant> getValues() const
63  {
64  return m_param_filterParameters;
65  }
66 
67  private:
69  std::map<std::string, FilterParamVariant> m_param_filterParameters;
70  };
71  }
73 }
74 
76  m_impl(std::make_unique<Impl>())
77 {
78 }
79 
81 
82 void
83 FilterParamMap::addParameter(ModuleParamList* moduleParamList, const std::string& name, const std::string& description)
84 {
85  m_impl->addParameter(moduleParamList, name, description);
86 }
87 
88 void
90 {
91  m_impl->assignTo(filterModuleParamList);
92 };
93 
94 // std::map<std::string, FilterParamVariant> FilterParamMap::getValues() const
95 // {
96 // return m_impl->getValues();
97 // }
Belle2::TrackFindingCDC::FilterParamMap::~FilterParamMap
~FilterParamMap()
Default destructor.
Belle2::TrackFindingCDC::FilterParamMap::Impl::addParameter
void addParameter(ModuleParamList *moduleParamList, const std::string &name, const std::string &description)
Add name, description and values to the module's parameter list.
Definition: FilterParamMap.cc:47
Belle2::TrackFindingCDC::AssignParameterVisitor::update
static void update(ModuleParamList *moduleParamList, const std::map< std::string, boost::variant< T... > > &valuesByName)
Transfer all the parameters from the map boost:variant values to the module parmeter list.
Definition: ParameterVariant.h:49
Belle2::TrackFindingCDC::FilterParamMap::assignTo
void assignTo(ModuleParamList *filterModuleParamList)
Unpack the map of parameters and forward them to the concrete filter.
Definition: FilterParamMap.cc:89
Belle2::ModuleParamList::addParameter
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Definition: ModuleParamList.templateDetails.h:38
Belle2::TrackFindingCDC::FilterParamMap::Impl
Define the implementation.
Definition: FilterParamMap.cc:42
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::FilterParamMap::Impl::getValues
std::map< std::string, FilterParamVariant > getValues() const
Retrieve the parameter (name,value) pairs.
Definition: FilterParamMap.cc:62
Belle2::TrackFindingCDC::FilterParamMap::m_impl
std::unique_ptr< Impl > m_impl
Pointer to implementation hiding the details.
Definition: FilterParamMap.h:72
Belle2::TrackFindingCDC::FilterParamMap::addParameter
void addParameter(ModuleParamList *moduleParamList, const std::string &name, const std::string &description)
Create one parameter in the parameter list for the module with the given name and desciption.
Definition: FilterParamMap.cc:83
Belle2::ModuleParam
A single parameter of the module.
Definition: DisplayUI.h:34
Belle2::TrackFindingCDC::FilterParamMap::FilterParamMap
FilterParamMap()
Default constructor.
Definition: FilterParamMap.cc:75
Belle2::TrackFindingCDC::FilterParamMap::Impl::assignTo
void assignTo(ModuleParamList *filterModuleParamList)
Assign values to the module-parameters in the module's list.
Definition: FilterParamMap.cc:56
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::FilterParamMap::Impl::m_param_filterParameters
std::map< std::string, FilterParamVariant > m_param_filterParameters
Parameter values.
Definition: FilterParamMap.cc:69