Belle II Software development
SegmentTrackFilterFactory.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/segmentTrack/SegmentTrackFilterFactory.h>
9
10#include <tracking/trackFindingCDC/filters/segmentTrack/SegmentTrackTruthVarSet.h>
11#include <tracking/trackFindingCDC/filters/segmentTrack/SegmentTrackVarSet.h>
12
13#include <tracking/trackFindingCDC/filters/base/MVAFilter.icc.h>
14#include <tracking/trackFindingCDC/filters/base/AllFilter.icc.h>
15#include <tracking/trackFindingCDC/filters/base/NoneFilter.icc.h>
16#include <tracking/trackFindingCDC/filters/base/TruthVarFilter.icc.h>
17#include <tracking/trackFindingCDC/filters/base/RecordingFilter.icc.h>
18
19#include <tracking/trackFindingCDC/filters/base/FilterVarSet.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 AllSegmentTrackFilter = AllFilter<BaseSegmentTrackFilter>;
30 using NoneSegmentTrackFilter = NoneFilter<BaseSegmentTrackFilter>;
31 using MCSegmentTrackFilter = TruthVarFilter<SegmentTrackTruthVarSet>;
33 using MVASegmentTrackFilter = MVAFilter<SegmentTrackVarSet>;
34}
35
37
38SegmentTrackFilterFactory::SegmentTrackFilterFactory(const std::string& defaultFilterName)
39 : Super(defaultFilterName)
40{
41}
42
43std::map<std::string, std::string>
45{
46 return {
47 {"none", "no segment track combination is valid"},
48 {"truth", "monte carlo truth"},
49 {"mva", "test with a mva method"},
50 {"recording", "record variables to a TTree"},
51 };
52}
53
54std::unique_ptr<BaseSegmentTrackFilter>
55SegmentTrackFilterFactory::create(const std::string& filterName) const
56{
57 if (filterName == "none") {
58 return std::make_unique<NoneSegmentTrackFilter>();
59 } else if (filterName == "truth") {
60 return std::make_unique<MCSegmentTrackFilter>();
61 } else if (filterName == "mva") {
62 return std::make_unique<MVASegmentTrackFilter>("trackfindingcdc_SegmentTrackFilter", 0.74);
63 } else if (filterName == "eval") {
64 auto recordedVarSets = std::make_unique<UnionVarSet<BaseSegmentTrackFilter::Object>>();
65 using TrackFilterVarSet = FilterVarSet<BaseSegmentTrackFilter>;
66 recordedVarSets->push_back(std::make_unique<TrackFilterVarSet>("mva", create("mva")));
67 recordedVarSets->push_back(std::make_unique<TrackFilterVarSet>("truth", create("truth")));
68 return std::make_unique<Recording<BaseSegmentTrackFilter>>(std::move(recordedVarSets), "SegmentTrackFilter_eval.root");
69 } else if (filterName == "recording") {
70 return std::make_unique<RecordingSegmentTrackFilter>("SegmentTrackFilter.root");
71 } else {
72 return Super::create(filterName);
73 }
74}
75
77{
78 return "Segment track chooser to be used during the combination of segment track pairs";
79}
80
82{
83 return "SegmentTrackFilter";
84}
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< BaseSegmentTrackFilter > create(const std::string &filterName) const
Create a filter with the given name, does not set filter specific parameters.
Class to compute floating point variables from a filter response which can be recorded as a flat TNtu...
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.
std::map< std::string, std::string > getValidFilterNamesAndDescriptions() const override
Getter for valid filter names and a description for each.
SegmentTrackFilterFactory(const std::string &defaultFilterName="mva")
Constructor forwarding the default filter name.
std::string getIdentifier() const override
Getter for a short identifier for the factory.
std::unique_ptr< BaseSegmentTrackFilter > create(const std::string &filterName) const override
Create a filter with the given name.
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.