/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/ds/include/RAT/DS/Classifier.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/ds/include/RAT/DS/Classifier.hh Source File
Ratpac-two
Classifier.hh
1 #ifndef __RAT_Classifier__
2 #define __RAT_Classifier__
3 
4 #include <TObject.h>
5 
6 #include <cmath>
7 #include <map>
8 #include <string>
9 #include <vector>
10 
11 namespace RAT {
12 namespace DS {
13 
14 class Classifier : public TObject {
15  public:
16  Classifier(std::string _name = "", std::string _tag = "") : TObject(), classifier_name(_name), tag(_tag) {}
17  virtual ~Classifier() {}
18 
19  // Classifier name
20  virtual const std::string &GetClassifierName() const { return classifier_name; }
21  virtual void SetClassifierName(const std::string &_name) { classifier_name = _name; }
22  virtual const std::string &GetTag() const { return tag; }
23  virtual void SetTag(const std::string &_tag) { tag = _tag; }
24  virtual const std::string GetFullName() const {
25  if (tag.empty()) return classifier_name;
26  return classifier_name + "__" + tag;
27  }
28  // Extract the base classifier name from a full name (strips the "__tag" suffix if present)
29  static std::string GetClassifierNameFromFullName(const std::string &full_name) {
30  size_t sep = full_name.find("__");
31  if (sep != std::string::npos) {
32  return full_name.substr(0, sep);
33  }
34  return full_name;
35  }
36 
37  // Classifier Results
38  virtual void SetClassificationResult(const std::string &name, double val) { classificationResults[name] = val; }
39  virtual double GetClassificationResult(const std::string &name) {
40  if (classificationResults.find(name) == classificationResults.end()) {
41  return NAN;
42  }
43  return classificationResults.at(name);
44  }
45 
46  // Classifier Results
47  std::map<std::string, double> classificationResults;
48 
49  ClassDef(Classifier, 2);
50 
51  protected:
52  std::string classifier_name; // name of the classifier that produced this result
53  std::string tag; // appended label for this specific classifier result
54 };
55 
56 } // namespace DS
57 } // namespace RAT
58 
59 #endif
Definition: Classifier.hh:14
Definition: CCCrossSecMessenger.hh:29