Belle II Software development
TCType.h
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#pragma once
9
10// framework:
11#include <framework/logging/Logger.h>
12
13// stl:
14#include <string>
15#include <map>
16
17
18
19namespace Belle2 {
25 class TCType {
26 public:
27
29 enum Type {
30 UnknownType, // the type of this TC is not even unclassified but completely unknown, normally a hint for errors
31 Unclassified, // a TC which was not classified yet
32 Lost, // reference TCs which were not found by test TF
33 RefOutlier, // reference TC which was rejected by some cuts or thresholds set by some classifier
34 Ghost, // did not reach m_PARAMqiThreshold
35 SmallStump, // TC too short
36 Clone, // reached threshold but for the same reference TC a better partner was already found
37 Contaminated, // more than m_PARAMqiThreshold in purity
38 Clean, // test TC has 100% purity for the particle type but not all hits of reference TC were found
39 Perfect, // test TC is identical with a reference TC (have exactly the same hits and no extra ones)
40 AllTCTypes, // all other test types are smaller than this value
41 Reference, // reference TC
42 NTypes // number of tcTypes available
43 };
44
45
46 // WARNING TODO: and isValidString (and for AlgorithmType the same...)
48 static bool isValidType(TCType::Type type)
49 {
50 return ((TCType::s_fromTypeToString.find(type) == TCType::s_fromTypeToString.end()) ? false : true);
51 }
52
53
55 static bool isValidName(std::string type)
56 {
57 return ((TCType::s_fromStringToType.find(type) == TCType::s_fromStringToType.end()) ? false : true);
58 }
59
60
62 static std::string getTypeName(TCType::Type type)
63 {
64 auto pos = TCType::s_fromTypeToString.find(type);
65 if (pos == TCType::s_fromTypeToString.end()) {
66 B2ERROR("TCType::getTypeName(): given iD " << type << " is not a valid TCType, returnint TCType::UnknownType!");
67 return TCType::s_fromTypeToString[UnknownType];
68 }
69 return pos->second;
70 }
71
72
74 static TCType::Type getTypeEnum(std::string type)
75 {
76 auto pos = TCType::s_fromStringToType.find(type);
77 if (pos == TCType::s_fromStringToType.end()) {
78 B2ERROR("TCType::getTypeName(): given iD " << type << " is not a valid TCType, returnint TCType::UnknownType!");
79 return TCType::s_fromStringToType[std::string("UnknownType")];
80 }
81 return pos->second;
82 }
83
84
86 static bool isReference(TCType::Type aType)
87 {
88 return aType == TCType::Reference
89 or aType == TCType::Lost
90 or aType == TCType::RefOutlier;
91 }
92
93
95 static bool isTestTC(TCType::Type aType)
96 {
97 return aType > TCType::RefOutlier
98 and aType < TCType::AllTCTypes;
99 }
100
101
103 static bool isGoodTestTC(TCType::Type aType)
104 {
105 return aType > TCType::Clone
106 and aType < TCType::AllTCTypes;
107 }
108
109
110 protected:
112 static std::map<Type, std::string> s_fromTypeToString;
113
115 static std::map<std::string, Type> s_fromStringToType;
116 };
117
118
119
121
122}
Small class for classifying types of reconstructed track candidates.
Definition: TCType.h:25
static std::string getTypeName(TCType::Type type)
for given TCType the corresponding string-name will be returned.
Definition: TCType.h:62
static bool isValidType(TCType::Type type)
checks if a type given is a valid type for a TCType
Definition: TCType.h:48
static bool isValidName(std::string type)
checks if the name given is a valid name for a TCType
Definition: TCType.h:55
static bool isTestTC(TCType::Type aType)
returns true if given TCType is a testTC-Type, false if not
Definition: TCType.h:95
Type
allows classifying TCs
Definition: TCType.h:29
static bool isReference(TCType::Type aType)
returns true if given TCType is a reference-Type, false if not
Definition: TCType.h:86
static std::map< std::string, Type > s_fromStringToType
static map allowing translation from a given name stored as a string to its type
Definition: TCType.h:115
static TCType::Type getTypeEnum(std::string type)
for given string name of a TCType the corresponding TCType will be returned.
Definition: TCType.h:74
static bool isGoodTestTC(TCType::Type aType)
returns true if given TCType is a testTC-Type and did successfully reconstruct a track
Definition: TCType.h:103
static std::map< Type, std::string > s_fromTypeToString
static map allowing translation from a given type to its name stored as a string
Definition: TCType.h:112
Abstract base class for different kinds of events.