Belle II Software  release-08-01-10
FilterFactory< AFilter > Class Template Referenceabstract

Factory that can create apropriate filter instances from a name. More...

#include <FilterFactory.dcl.h>

Collaboration diagram for FilterFactory< AFilter >:

Public Types

using CreatedFilter = AFilter
 Type of the filter that this factory creates.
 

Public Member Functions

 FilterFactory (const std::string &defaultFilterName="")
 Fill the default filter name values.
 
virtual ~FilterFactory ()
 Make destructor of interface class virtual.
 
virtual std::string getIdentifier () const =0
 Getter for a short identifier of the factory. Currently unused.
 
virtual std::string getFilterPurpose () const =0
 Getter for a descriptive purpose of the filter.
 
virtual std::map< std::string, std::string > getValidFilterNamesAndDescriptions () const =0
 Getter for the valid filter names and a description for each.
 
virtual std::unique_ptr< AFilter > create (const std::string &filterName) const
 Create a filter with the given name, does not set filter specific parameters. More...
 
virtual std::string createFiltersNameDescription () const
 Create a string with a description mentioning the names of the chooseable filter.
 
virtual std::string createFiltersParametersDescription () const
 Create a string with a description mentioning the parameters of the chooseable filter.
 
const std::string & getDefaultFilterName () const
 Legacy - Return the default filter suggested by the factory.
 

Private Attributes

std::string m_defaultFilterName
 Legacy - Default filter name suggested by this factory.
 

Detailed Description

template<class AFilter>
class Belle2::TrackFindingCDC::FilterFactory< AFilter >

Factory that can create apropriate filter instances from a name.

Definition at line 25 of file FilterFactory.dcl.h.

Member Function Documentation

◆ create()

std::unique_ptr< AFilter > create ( const std::string &  filterName) const
virtual

Create a filter with the given name, does not set filter specific parameters.

Always emits an error and returns nullptr

Reimplemented in TrackletFilterFactory, RelationFilterFactory, PathFilterFactory, WireHitFilterFactory, TrackQualityFilterFactory, TrackFilterFactory, StereoHitFilterFactory, SegmentTripleRelationFilterFactory, SegmentTripleFilterFactory, SegmentTrackFilterFactory, SegmentRelationFilterFactory, SegmentFilterFactory, FacetRelationFilterFactory, ClusterFilterFactory, AxialSegmentPairFilterFactory, SVDStateFilterFactory, SVDResultFilterFactory, SVDPairFilterFactory, PXDStateFilterFactory, PXDResultFilterFactory, PXDPairFilterFactory, CDCStateFilterFactory, CDCPathFilterFactory, CDCPathPairFilterFactory, TrackRelationFilterFactory, SegmentPairRelationFilterFactory, SegmentPairFilterFactory, and FacetFilterFactory.

Definition at line 44 of file FilterFactory.icc.h.

45  {
46  // Check whether false positive or false negative filter are requested
47  while (filterName == "false_positive" or filterName == "false_negative") {
48  std::string truthFilterName = "truth";
49  std::unique_ptr<AFilter> truthFilter = this->create(truthFilterName);
50  std::unique_ptr<AFilter> defaultFilter = this->create(m_defaultFilterName);
51 
52  if (not truthFilter or not defaultFilter) break;
53 
54  if (filterName == "false_positive") {
55  std::unique_ptr<AFilter> notTruthFilter =
56  std::make_unique<NotFilter<AFilter>>(std::move(truthFilter));
57  return std::make_unique<AndFilter<AFilter>>(std::move(notTruthFilter),
58  std::move(defaultFilter));
59  }
60 
61  if (filterName == "false_negative") {
62  std::unique_ptr<AFilter> notDefaultFilter =
63  std::make_unique<NotFilter<AFilter>>(std::move(defaultFilter));
64  return std::make_unique<AndFilter<AFilter>>(std::move(notDefaultFilter),
65  std::move(truthFilter));
66  }
67  break;
68  }
69 
70  // Filter not valid
71  B2ERROR("Could not create filter with name " << filterName);
72  std::ostringstream message;
73  message << "Known filter names are: ";
74  std::vector<std::string> quotedFilterNames;
75  for (const auto& filterNameAndDescription : getValidFilterNamesAndDescriptions()) {
76  const std::string& validFilterName = filterNameAndDescription.first;
77  quotedFilterNames.push_back(quoted(validFilterName));
78  }
79  message << join(", ", quotedFilterNames);
80  message << ".";
81  B2ERROR(message.str());
82  return std::unique_ptr<AFilter>(nullptr);
83  }
std::string m_defaultFilterName
Legacy - Default filter name suggested by this factory.
virtual std::unique_ptr< AFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
virtual std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const =0
Getter for the valid filter names and a description for each.

The documentation for this class was generated from the following files: