Belle II Software development
SegmentFilterFactory.cc
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#include <tracking/trackFindingCDC/filters/segment/SegmentFilterFactory.h>
9
10#include <tracking/trackFindingCDC/filters/segment/BkgTruthSegmentVarSet.h>
11
12#include <tracking/trackFindingCDC/filters/segment/AdvancedSegmentVarSet.h>
13
14#include <tracking/trackFindingCDC/filters/base/MVAFilter.icc.h>
15
16#include <tracking/trackFindingCDC/filters/base/RecordingFilter.icc.h>
17#include <tracking/trackFindingCDC/filters/base/TruthVarFilter.icc.h>
18#include <tracking/trackFindingCDC/filters/base/AllFilter.icc.h>
19#include <tracking/trackFindingCDC/filters/base/NoneFilter.icc.h>
20
21#include <tracking/trackFindingCDC/filters/base/FilterFactory.icc.h>
22
23#include <tracking/trackFindingCDC/varsets/VariadicUnionVarSet.h>
24
25using namespace Belle2;
26using namespace TrackFindingCDC;
27
28namespace {
29 using AllSegmentFilter = AllFilter<BaseSegmentFilter>;
30 using NoneSegmentFilter = NoneFilter<BaseSegmentFilter>;
31 using BkgMCSegmentFilter = TruthVarFilter<BkgTruthSegmentVarSet>;
32 using BkgRecordingSegmentFilter =
34 using BkgMVASegmentFilter = MVAFilter<AdvancedSegmentVarSet>;
35}
36
38
39SegmentFilterFactory::SegmentFilterFactory(const std::string& defaultFilterName)
40 : Super(defaultFilterName)
41{
42}
43
45{
46 return "Segment";
47}
48
50{
51 return "Segment filter to reject fakes";
52}
53
54std::map<std::string, std::string>
56{
57 return {
58 {"none", "no segment track combination is valid"},
59 {"all", "filter out all segments as background"},
60 {"bkg_truth", "monte carlo truth"},
61 {"bkg_recording", "record variables to a TTree"},
62 {"bkg_mva", "test with a mva method"}
63 };
64}
65
66std::unique_ptr<BaseSegmentFilter>
67SegmentFilterFactory::create(const std::string& filterName) const
68{
69 if (filterName == "none") {
70 return std::make_unique<NoneSegmentFilter>();
71 // cppcheck-suppress knownConditionTrueFalse
72 } else if (filterName == "all") {
73 return std::make_unique<AllSegmentFilter>();
74 // cppcheck-suppress knownConditionTrueFalse
75 } else if (filterName == "bkg_truth") {
76 return std::make_unique<BkgMCSegmentFilter>();
77 // cppcheck-suppress knownConditionTrueFalse
78 } else if (filterName == "bkg_recording") {
79 return std::make_unique<BkgRecordingSegmentFilter>("BackgroundSegmentFilter.root");
80 // cppcheck-suppress knownConditionTrueFalse
81 } else if (filterName == "bkg_mva") {
82 return std::make_unique<BkgMVASegmentFilter>("trackfindingcdc_BackgroundSegmentFilter");
83 } else {
84 return Super::create(filterName);
85 }
86}
Filter adapter type that accepts all items (just for reference).
Definition: AllFilter.dcl.h:21
Factory that can create apropriate filter instances from a name.
virtual std::unique_ptr< BaseSegmentFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
Convience template to create a mva filter for a set of variables.
Filter adapter type that rejects all items.
Convience template to create a recording filter for a set of variables.
SegmentFilterFactory(const std::string &defaultFilterName="all")
Constructor forwarding the default filter name.
std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const override
Getter for valid filter names and a description for each.
std::unique_ptr< BaseSegmentFilter > create(const std::string &filterName) const override
Create a filter with the given name.
std::string getIdentifier() const override
Getter for a short identifier for the factory.
std::string getFilterPurpose() const override
Getter for a descriptive purpose of the constructed filters.
MC Filter Type using a VarSet and the truth variable in it.
Abstract base class for different kinds of events.