Belle II Software  release-05-02-19
FilterVarSet.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/varsets/VarSet.h>
13 #include <tracking/trackFindingCDC/varsets/VarNames.h>
14 
15 #include <tracking/trackFindingCDC/utilities/Named.h>
16 #include <tracking/trackFindingCDC/utilities/MayBePtr.h>
17 
18 #include <RtypesCore.h>
19 
20 #include <string>
21 #include <memory>
22 
23 namespace Belle2 {
28  namespace TrackFindingCDC {
29 
31  template<class AFilter>
32  struct FilterVarNames : public VarNames<typename AFilter::Object> {
33 
35  static const size_t nVars;
36 
38  static constexpr char const* getName(int iName);
39  };
40 
48  template <class AFilter>
49  class FilterVarSet : public VarSet<FilterVarNames<AFilter>> {
50 
51  private:
54 
55  public:
57  using Filter = AFilter;
58 
60  using Object = typename Filter::Object;
61 
63  FilterVarSet(const std::string& filterName = "");
64 
66  FilterVarSet(const std::string& filterName, std::unique_ptr<Filter> ptrFilter);
67 
68  using Super::named;
69 
71  bool extract(const Object* obj) final;
72 
74  void initialize() final;
75 
80  std::vector<Named<Float_t*>> getNamedVariables(const std::string& prefix) override;
81 
86  MayBePtr<Float_t> find(const std::string& varName) override;
87 
88  public:
90  double m_cut = NAN;
91 
93  std::string m_filterName;
94 
96  std::string m_filterNamePrefix;
97 
99  std::unique_ptr<Filter> m_ptrFilter;
100  };
101  }
103 }
Belle2::TrackFindingCDC::Named
A mixin class to attach a name to an object.
Definition: Named.h:33
Belle2::TrackFindingCDC::FilterVarSet::FilterVarSet
FilterVarSet(const std::string &filterName="")
Construct the varset making an instance of the template filter.
Definition: FilterVarSet.icc.h:57
Belle2::TrackFindingCDC::FilterVarSet::find
MayBePtr< Float_t > find(const std::string &varName) override
Pointer to the variable with the given name.
Definition: FilterVarSet.icc.h:118
Belle2::TrackFindingCDC::FilterVarSet::extract
bool extract(const Object *obj) final
Generate filter weight variable from the object.
Definition: FilterVarSet.icc.h:76
Belle2::TrackFindingCDC::FilterVarSet::Object
typename Filter::Object Object
Type of the object from which the filter judgement should be extracted.
Definition: FilterVarSet.dcl.h:68
Belle2::TrackFindingCDC::FilterVarSet::initialize
void initialize() final
Initialize the filter before event processing.
Definition: FilterVarSet.icc.h:93
Belle2::TrackFindingCDC::FilterVarSet::m_cut
double m_cut
The cut on the filter output.
Definition: FilterVarSet.dcl.h:98
Belle2::TrackFindingCDC::FilterVarNames::nVars
static const size_t nVars
Number of variables to be generated.
Definition: FilterVarSet.dcl.h:43
Belle2::TrackFindingCDC::BaseVarSet< FilterVarNames< AFilter > ::Object >::getNamedVariables
std::vector< Named< Float_t * > > getNamedVariables()
Getter for the named references to the individual variables.
Definition: BaseVarSet.h:80
Belle2::TrackFindingCDC::FilterVarSet::m_filterName
std::string m_filterName
Name of the filter.
Definition: FilterVarSet.dcl.h:101
Belle2::TrackFindingCDC::FilterVarSet::Super
VarSet< FilterVarNames< AFilter > > Super
Type of the base class.
Definition: FilterVarSet.dcl.h:61
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::FilterVarNames::getName
static constexpr char const * getName(int iName)
Getter for the name at the given index.
Definition: FilterVarSet.icc.h:51
Belle2::TrackFindingCDC::FilterVarSet::m_ptrFilter
std::unique_ptr< Filter > m_ptrFilter
Filter from which to generate weight as a variable set;.
Definition: FilterVarSet.dcl.h:107
Belle2::TrackFindingCDC::FilterVarSet::m_filterNamePrefix
std::string m_filterNamePrefix
Prefix to be put in front of the filter variables.
Definition: FilterVarSet.dcl.h:104
Belle2::TrackFindingCDC::FilterVarSet::Filter
AFilter Filter
Type of the filter.
Definition: FilterVarSet.dcl.h:65
Belle2::TrackFindingCDC::VarSet< FilterVarNames< AFilter > >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::VarSet
Generic class that generates some named float values from a given object.
Definition: VarSet.h:46
Belle2::TrackFindingCDC::FilterVarSet
Class to compute floating point variables from a filter response which can be recorded as a flat TNtu...
Definition: FilterVarSet.dcl.h:57
Belle2::TrackFindingCDC::Filter::Object
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:43