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/trackingUtilities/filters/base/NoneFilter.icc.h>
17
18#include <tracking/trackingUtilities/filters/base/AndFilter.icc.h>
19#include <tracking/trackingUtilities/filters/base/NotFilter.icc.h>
20
21#include <tracking/trackingUtilities/filters/base/FilterFactory.icc.h>
22
23
24using namespace Belle2;
25using namespace TrackFindingCDC;
26using namespace TrackingUtilities;
27
29
31 : Super(defaultFilterName)
32{
33}
34
36{
37 return "SegmentRelation";
38}
39
41{
42 return "Segment relation filter to construct a segment network for in super cluster merging";
43}
44
45std::map<std::string, std::string>
47{
48 return {
49 {"none", "no segment relation is valid, stop at segment creation."},
50 {"truth", "segment relations from monte carlo truth"},
51 {"unionrecording", "record many multiple choosable variable set"},
52 {"feasible", "check if the segment relation is feasible"},
53 {"realistic", "check if the segment relation is a good combination"},
54 {"false_positive", "accepts the instances that are really false but are accepted by the default filter"},
55 {"false_negative", "accepts the instances that are really true but are rejected by the default filter"},
56 };
57}
58
59std::unique_ptr<BaseSegmentRelationFilter >
60SegmentRelationFilterFactory::create(const std::string& filterName) const
61{
62 if (filterName == "none") {
63 return std::make_unique<NoneFilter<BaseSegmentRelationFilter>>();
64 } else if (filterName == "truth") {
65 return std::make_unique<MCSegmentRelationFilter>();
66 } else if (filterName == "unionrecording") {
67 return std::make_unique<UnionRecordingSegmentRelationFilter>();
68 } else if (filterName == "feasible") {
69 return std::make_unique<MVAFeasibleSegmentRelationFilter>();
70 } else if (filterName == "realistic") {
71 return std::make_unique<MVARealisticSegmentRelationFilter>();
72 } else if (filterName == "false_positive") {
73 std::string defaultFilterName = this->getDefaultFilterName();
74 auto defaultFilter = this->create(defaultFilterName);
75 std::string truthFilterName = "truth";
76 auto truthFilter = this->create(truthFilterName);
77 auto notTruthFilter = std::make_unique<NotFilter<BaseSegmentRelationFilter>>(std::move(truthFilter));
78 return std::make_unique<AndFilter<BaseSegmentRelationFilter>>(std::move(notTruthFilter),
79 std::move(defaultFilter));
80 } else if (filterName == "false_negative") {
81 std::string defaultFilterName = this->getDefaultFilterName();
82 auto defaultFilter = this->create(defaultFilterName);
83 std::string truthFilterName = "truth";
84 auto truthFilter = this->create(truthFilterName);
85 auto notDefaultFilter = std::make_unique<NotFilter<BaseSegmentRelationFilter>>(std::move(defaultFilter));
86 return std::make_unique<AndFilter<BaseSegmentRelationFilter>>(std::move(notDefaultFilter),
87 std::move(truthFilter));
88 } else {
89 return Super::create(filterName);
90 }
91}
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.
TrackingUtilities::FilterFactory< BaseSegmentRelationFilter > Super
Type of the base class.
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.
Factory that can create appropriate filter instances from a name.
virtual std::unique_ptr< BaseSegmentRelationFilter > create(const std::string &filterName) const
Abstract base class for different kinds of events.