Belle II Software  release-08-01-10
ChoosableFromVarSetFilter.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/FilterOnVarSet.dcl.h>
11 
12 #include <tracking/trackFindingCDC/varsets/BaseVarSet.h>
13 
14 #include <RtypesCore.h>
15 
16 #include <string>
17 #include <memory>
18 
19 namespace Belle2 {
24  class ModuleParamList;
25  namespace TrackFindingCDC {
26 
31  template <class AFilter>
32  class ChoosableFromVarSet : public OnVarSet<AFilter> {
33 
34  private:
37 
38  public:
40  using Object = typename AFilter::Object;
41 
42  private:
45 
46  public:
51  ChoosableFromVarSet(std::unique_ptr<AVarSet> varSet, std::string varName = "");
52 
55 
57  void exposeParameters(ModuleParamList* parameterList, const std::string& prefix) override;
58 
60  void initialize() override;
61 
63  Weight operator()(const Object& object) override;
64 
65  private:
67  std::string m_param_varName;
68 
70  Float_t* m_variable = nullptr;
71  };
72 
74  template <class ATruthVarSet>
76  : public ChoosableFromVarSet<Filter<typename ATruthVarSet::Object>> {
77 
78  private:
81 
82  public:
84  using Object = typename ATruthVarSet::Object;
85 
86  public:
88  ChoosableFromVarSetFilter(const std::string& varName = "");
89 
92  };
93  }
95 }
The Module parameter list class.
Generic class that generates some named float values from a given object.
Definition: BaseVarSet.h:33
Convience template to create a filter returning on variable from a set of variables.
typename ATruthVarSet::Object Object
Type of the filtered object.
ChoosableFromVarSetFilter(const std::string &varName="")
Constructor.
Filter adapter to make a filter work on a set of variables and return on variable as the result of th...
Weight operator()(const Object &object) override
Returns the variable with the set requested name from the variable set.
void exposeParameters(ModuleParamList *parameterList, const std::string &prefix) override
Add the parameters of this filter to the given parameter list.
void initialize() override
Initialisation method sets up a reference to the value in the variable set to be returned.
Float_t * m_variable
Reference to the location of the value in the variable set to be returned.
typename AFilter::Object Object
Type of the filtered object.
std::string m_param_varName
Memory for the name of the variable selected as the return value of the filter.
ChoosableFromVarSet(std::unique_ptr< AVarSet > varSet, std::string varName="")
Constructor taking the variable set the filter should work on and the default name of the variable to...
Filter adapter to make a filter work on a set of variables.
Abstract base class for different kinds of events.