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