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

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/ds/include/RAT/DS/FitResult.hh Source File
Ratpac-two
FitResult.hh
1 #ifndef __RAT_FitResult__
2 #define __RAT_FitResult__
3 
4 #include <TObject.h>
5 #include <TVector3.h>
6 
7 #include <RAT/DS/Classifier.hh>
8 #include <RAT/Log.hh>
9 #include <map>
10 #include <string>
11 
12 namespace RAT {
13 namespace DS {
14 
15 class FitResult : public TObject {
16  public:
17  FitResult(std::string _name = "", std::string _tag = "")
18  : TObject(),
19  fitter_name(_name),
20  tag(_tag),
21  fit_position(-1e9, -1e9, -1e9),
22  fit_direction(0, 0, 0),
23  fit_energy(-1e9),
24  fit_time(-1e9) {}
25  virtual ~FitResult() {}
26 
27  // Fitter name
28  virtual const std::string &GetFitterName() const { return fitter_name; }
29  virtual void SetFitterName(const std::string &_name) { fitter_name = _name; }
30  virtual const std::string &GetTag() const { return tag; }
31  virtual void SetTag(const std::string &_tag) { tag = _tag; }
32  virtual const std::string GetFullName() const {
33  if (tag.empty()) return fitter_name;
34  return fitter_name + "__" + tag;
35  }
36  // Extract the base fitter name from a full name (strips the "__tag" suffix if present)
37  static std::string GetFitterNameFromFullName(const std::string &full_name) {
38  size_t sep = full_name.find("__");
39  if (sep != std::string::npos) {
40  return full_name.substr(0, sep);
41  }
42  return full_name;
43  }
44 
45  // Fitted Position
46  virtual const TVector3 &GetPosition() const { return fit_position; }
47  virtual void SetPosition(const TVector3 &_pos) {
48  fit_position = _pos;
49  SetValidPosition(true);
50  SetEnablePosition(true);
51  }
52  virtual const bool GetValidPosition() { return valid_position; }
53  virtual void SetValidPosition(const bool _valid) { valid_position = _valid; }
54  virtual const bool GetEnablePosition() { return enable_position; }
55  virtual void SetEnablePosition(const bool _enable) { enable_position = _enable; }
56 
57  // Fitted Direction
58  virtual const TVector3 &GetDirection() const { return fit_direction; }
59  virtual void SetDirection(const TVector3 &_dir) {
60  fit_direction = _dir;
61  SetValidDirection(true);
62  SetEnableDirection(true);
63  }
64  virtual const bool GetValidDirection() { return valid_direction; }
65  virtual void SetValidDirection(const bool _valid) { valid_direction = _valid; }
66  virtual const bool GetEnableDirection() { return enable_direction; }
67  virtual void SetEnableDirection(const bool _enable) { enable_direction = _enable; }
68 
69  // Fitted Energy
70  virtual const double GetEnergy() { return fit_energy; }
71  virtual void SetEnergy(const double _energy) {
72  fit_energy = _energy;
73  SetValidEnergy(true);
74  SetEnableEnergy(true);
75  }
76  virtual const bool GetValidEnergy() { return valid_energy; }
77  virtual void SetValidEnergy(const bool _valid) { valid_energy = _valid; }
78  virtual const bool GetEnableEnergy() { return enable_energy; }
79  virtual void SetEnableEnergy(const bool _enable) { enable_energy = _enable; }
80 
81  // Fitted Time
82  virtual const double GetTime() { return fit_time; }
83  virtual void SetTime(const double _time) {
84  fit_time = _time;
85  SetValidTime(true);
86  SetEnableTime(true);
87  }
88  virtual const bool GetValidTime() { return valid_time; }
89  virtual void SetValidTime(const bool _valid) { valid_time = _valid; }
90  virtual const bool GetEnableTime() { return enable_time; }
91  virtual void SetEnableTime(const bool _enable) { enable_time = _enable; }
92 
93  // Figure of Merit
94  void SetFigureOfMerit(const std::string &name, double value) { figuresOfMerit[name] = value; }
95  double GetFigureOfMerit(const std::string &name) {
96  if (figuresOfMerit.find(name) == figuresOfMerit.end()) {
97  return -9999;
98  }
99  return figuresOfMerit.at(name);
100  }
101 
102  std::map<std::string, double> figuresOfMerit;
103 
104  // Classification
105  std::map<std::string, Classifier> classifiers;
106 
107  ClassDef(FitResult, 2);
108 
109  protected:
110  std::string fitter_name; // name of the fitter that produced this result
111  std::string tag; // label for this specific fit result
112  // Fit values
113  TVector3 fit_position;
114  TVector3 fit_direction;
115  double fit_energy;
116  double fit_time;
117  // Fit validity
118  bool valid_position = false;
119  bool valid_direction = false;
120  bool valid_energy = false;
121  bool valid_time = false;
122  // Fit enabled
123  bool enable_position = false;
124  bool enable_direction = false;
125  bool enable_energy = false;
126  bool enable_time = false;
127 };
128 
129 } // namespace DS
130 } // namespace RAT
131 
132 #endif
Definition: FitResult.hh:15
Definition: CCCrossSecMessenger.hh:29