Belle II Software development
SegmentRelationFilterFactory.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/segmentRelation/SegmentRelationFilterFactory.h>
9
10#include <tracking/trackFindingCDC/filters/segmentRelation/BaseSegmentRelationFilter.h>
11#include <tracking/trackFindingCDC/filters/segmentRelation/MCSegmentRelationFilter.h>
12#include <tracking/trackFindingCDC/filters/segmentRelation/UnionRecordingSegmentRelationFilter.h>
13#include <tracking/trackFindingCDC/filters/segmentRelation/MVAFeasibleSegmentRelationFilter.h>
14#include <tracking/trackFindingCDC/filters/segmentRelation/MVARealisticSegmentRelationFilter.h>
15
16#include <tracking/trackFindingCDC/filters/base/NoneFilter.icc.h>
17
18#include <tracking/trackFindingCDC/filters/base/AndFilter.icc.h>
19#include <tracking/trackFindingCDC/filters/base/NotFilter.icc.h>
20
21#include <tracking/trackFindingCDC/filters/base/FilterFactory.icc.h>
22
23
24using namespace Belle2;
25using namespace TrackFindingCDC;
26
28
30 : Super(defaultFilterName)
31{
32}
33
35{
36 return "SegmentRelation";
37}
38
40{
41 return "Segment relation filter to construct a segment network for in super cluster merging";
42}
43
44std::map<std::string, std::string>
46{
47 return {
48 {"none", "no segment relation is valid, stop at segment creation."},
49 {"truth", "segment relations from monte carlo truth"},
50 {"unionrecording", "record many multiple choosable variable set"},
51 {"feasible", "check if the segment relation is feasible"},
52 {"realistic", "check if the segment relation is a good combination"},
53 {"false_positive", "accepts the instances that are really false but are accepted by the default filter"},
54 {"false_negative", "accepts the instances that are really true but are rejected by the default filter"},
55 };
56}
57
58std::unique_ptr<BaseSegmentRelationFilter >
59SegmentRelationFilterFactory::create(const std::string& filterName) const
60{
61 if (filterName == "none") {
62 return std::make_unique<NoneFilter<BaseSegmentRelationFilter>>();
63 } else if (filterName == "truth") {
64 return std::make_unique<MCSegmentRelationFilter>();
65 } else if (filterName == "unionrecording") {
66 return std::make_unique<UnionRecordingSegmentRelationFilter>();
67 } else if (filterName == "feasible") {
68 return std::make_unique<MVAFeasibleSegmentRelationFilter>();
69 } else if (filterName == "realistic") {
70 return std::make_unique<MVARealisticSegmentRelationFilter>();
71 } else if (filterName == "false_positive") {
72 std::string defaultFilterName = this->getDefaultFilterName();
73 auto defaultFilter = this->create(defaultFilterName);
74 std::string truthFilterName = "truth";
75 auto truthFilter = this->create(truthFilterName);
76 auto notTruthFilter = std::make_unique<NotFilter<BaseSegmentRelationFilter>>(std::move(truthFilter));
77 return std::make_unique<AndFilter<BaseSegmentRelationFilter>>(std::move(notTruthFilter),
78 std::move(defaultFilter));
79 } else if (filterName == "false_negative") {
80 std::string defaultFilterName = this->getDefaultFilterName();
81 auto defaultFilter = this->create(defaultFilterName);
82 std::string truthFilterName = "truth";
83 auto truthFilter = this->create(truthFilterName);
84 auto notDefaultFilter = std::make_unique<NotFilter<BaseSegmentRelationFilter>>(std::move(defaultFilter));
85 return std::make_unique<AndFilter<BaseSegmentRelationFilter>>(std::move(notDefaultFilter),
86 std::move(truthFilter));
87 } else {
88 return Super::create(filterName);
89 }
90}
Factory that can create apropriate filter instances from a name.
virtual std::unique_ptr< BaseSegmentRelationFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
const std::string & getDefaultFilterName() const
Legacy - Return the default filter suggested by the factory.
std::unique_ptr< BaseSegmentRelationFilter > create(const std::string &filterName) const override
Create a filter with the given name.
std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const override
Getter for valid filter names and a description for each.
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.
SegmentRelationFilterFactory(const std::string &defaultFilterName="realistic")
Constructor forwarding the default filter name.
Abstract base class for different kinds of events.